From 7378f5ddf46ef0317343ad310d703c4f4ff8d703 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Fri, 8 Mar 2002 19:44:37 +0000 Subject: Initial stuff for checking requisites and previous versions. --- lib/sisfile.cpp | 6 ++++++ lib/sisfile.h | 13 +++++++++++++ lib/sisfileheader.cpp | 16 ++++++++++++++++ lib/sisfileheader.h | 5 +++++ lib/sistypes.h | 6 ++++++ 5 files changed, 46 insertions(+) (limited to 'lib') diff --git a/lib/sisfile.cpp b/lib/sisfile.cpp index ec8adb8..634266f 100644 --- a/lib/sisfile.cpp +++ b/lib/sisfile.cpp @@ -27,6 +27,12 @@ #include +SisRC +SISFile::compareApp(SISFile* other) +{ + return m_header.compareApp(&other->m_header); +} + SisRC SISFile::fillFrom(uint8_t* buf, off_t len) { 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. * @@ -62,6 +70,11 @@ public: */ uint8_t* getName(); + /** + * Is this the same application? + */ + bool sameApp(SISFile* other); + /** * Set the installed drive. */ diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp index 19724c3..97e0687 100644 --- a/lib/sisfileheader.cpp +++ b/lib/sisfileheader.cpp @@ -28,6 +28,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) { diff --git a/lib/sisfileheader.h b/lib/sisfileheader.h index 6b5fa3f..0c2d635 100644 --- a/lib/sisfileheader.h +++ b/lib/sisfileheader.h @@ -35,6 +35,11 @@ class SISFileHeader { public: + /** + * Compare uid and version number of this file, with another. + */ + SisRC compareApp(SISFileHeader* other); + /** * Populate the fields. * 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); -- cgit v1.2.3