diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisfile.cpp | 6 | ||||
-rw-r--r-- | lib/sisfile.h | 13 | ||||
-rw-r--r-- | lib/sisfileheader.cpp | 16 | ||||
-rw-r--r-- | lib/sisfileheader.h | 5 | ||||
-rw-r--r-- | lib/sistypes.h | 6 |
5 files changed, 46 insertions, 0 deletions
diff --git a/lib/sisfile.cpp b/lib/sisfile.cpp index ec8adb8..634266f 100644 --- a/lib/sisfile.cpp +++ b/lib/sisfile.cpp @@ -28,6 +28,12 @@ #include <stdio.h> SisRC +SISFile::compareApp(SISFile* other) +{ + return m_header.compareApp(&other->m_header); +} + +SisRC SISFile::fillFrom(uint8_t* buf, off_t len) { int ix = 0; diff --git a/lib/sisfile.h b/lib/sisfile.h index cae00ee..2bfcea5 100644 --- a/lib/sisfile.h +++ b/lib/sisfile.h @@ -38,6 +38,14 @@ class SISReqRecord; class SISFile { public: + + /** + * Compare uid and version number of this file, with another. + * + * @see SISFileHeader::compareApp() + */ + SisRC compareApp(SISFile* other); + /** * Populate the fields. * @@ -63,6 +71,11 @@ public: uint8_t* getName(); /** + * Is this the same application? + */ + bool sameApp(SISFile* other); + + /** * Set the installed drive. */ void setDrive(char drive); diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp index 19724c3..97e0687 100644 --- a/lib/sisfileheader.cpp +++ b/lib/sisfileheader.cpp @@ -29,6 +29,22 @@ const int OFF_NUMBER_OF_FILES = 26; const int OFF_INSTALLATION_DRIVE = 28; SisRC +SISFileHeader::compareApp(SISFileHeader* other) +{ + if (m_uid1 != other->m_uid1) + return SIS_DIFFERENT_APP; + if ((m_major < other->m_major) || + ((m_major == other->m_major) && + (m_minor < other->m_minor))) + return SIS_VER_EARLIER; + if ((m_major == other->m_major) && + (m_minor == other->m_minor) && + (m_variant != other->m_variant)) + return SIS_OTHER_VARIANT; + return SIS_SAME_OR_LATER; +} + +SisRC SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len) { if (*base + 68 > len) diff --git a/lib/sisfileheader.h b/lib/sisfileheader.h index 6b5fa3f..0c2d635 100644 --- a/lib/sisfileheader.h +++ b/lib/sisfileheader.h @@ -36,6 +36,11 @@ class SISFileHeader public: /** + * Compare uid and version number of this file, with another. + */ + SisRC compareApp(SISFileHeader* other); + + /** * Populate the fields. * * @param buf The buffer to read from. diff --git a/lib/sistypes.h b/lib/sistypes.h index 12f237b..a5d008f 100644 --- a/lib/sistypes.h +++ b/lib/sistypes.h @@ -32,6 +32,12 @@ enum SisRC { SIS_OK = 0, SIS_TRUNCATED, SIS_CORRUPTED, + SIS_FAILED, + SIS_ABORTED, + SIS_DIFFERENT_APP, + SIS_VER_EARLIER, + SIS_SAME_OR_LATER, + SIS_OTHER_VARIANT, }; extern uint16_t read16(uint8_t* p); |