[Scummvm-git-logs] scummvm master -> 077d4121a18d3885713ceab3609a43dd527f526b

bluegr noreply at scummvm.org
Fri Dec 29 09:15:21 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
968aa2fcd6 COMMON: Add support for opening an InstallShield cab inside of an archive
077d4121a1 MTROPOLIS: Add InstallShield cab archive type


Commit: 968aa2fcd65159458115fbb640089235796a3588
    https://github.com/scummvm/scummvm/commit/968aa2fcd65159458115fbb640089235796a3588
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2023-12-29T11:15:17+02:00

Commit Message:
COMMON: Add support for opening an InstallShield cab inside of an archive

Changed paths:
    common/compression/installshield_cab.cpp
    common/compression/installshield_cab.h


diff --git a/common/compression/installshield_cab.cpp b/common/compression/installshield_cab.cpp
index 45bd16e23a2..6a4610c42bd 100644
--- a/common/compression/installshield_cab.cpp
+++ b/common/compression/installshield_cab.cpp
@@ -87,7 +87,7 @@ class InstallShieldCabinet : public Archive {
 public:
 	InstallShieldCabinet();
 
-	bool open(const Path *baseName, const FSNode *node);
+	bool open(const Path *baseName, Common::Archive *archive, const FSNode *node);
 	void close();
 
 	// Archive API implementation
@@ -127,7 +127,7 @@ private:
 	FileMap _map;
 	Path _baseName;
 	Common::Array<VolumeHeader> _volumeHeaders;
-	bool _useSearchMan;
+	Common::Archive *_archive;
 
 	static bool readVolumeHeader(SeekableReadStream *volumeStream, VolumeHeader &inVolumeHeader);
 
@@ -135,17 +135,17 @@ private:
 	Path getVolumeName(uint volume) const;
 };
 
-InstallShieldCabinet::InstallShieldCabinet() : _version(0), _useSearchMan(false) {
+InstallShieldCabinet::InstallShieldCabinet() : _version(0), _archive(nullptr) {
 }
 
-bool InstallShieldCabinet::open(const Path *baseName, const FSNode *node) {
+bool InstallShieldCabinet::open(const Path *baseName, Common::Archive *archive, const FSNode *node) {
 	// Store the base name so we can generate file names
 	if (baseName) {
 		_baseName = *baseName;
-		_useSearchMan = true;
+		_archive = archive;
 	} else if (node) {
 		_baseName = node->getPath();
-		_useSearchMan = false;
+		_archive = nullptr;
 	} else {
 		return false;
 	}
@@ -162,8 +162,8 @@ bool InstallShieldCabinet::open(const Path *baseName, const FSNode *node) {
 	// First, open all the .cab files and read their headers
 	uint volume = 1;
 	for (;;) {
-		if (_useSearchMan) {
-			file.reset(SearchMan.createReadStreamForMember(getVolumeName(volume++)));
+		if (_archive) {
+			file.reset(_archive->createReadStreamForMember(getVolumeName(volume++)));
 			if (!file.get()) {
 				break;
 			}
@@ -179,11 +179,11 @@ bool InstallShieldCabinet::open(const Path *baseName, const FSNode *node) {
 	}
 
 	// Try to open a header (.hdr) file to get the file list
-	if (_useSearchMan) {
-		file.reset(SearchMan.createReadStreamForMember(getHeaderName()));
+	if (_archive) {
+		file.reset(_archive->createReadStreamForMember(getHeaderName()));
 		if (!file) {
 			// No header file is present, file list is in first .cab file
-			file.reset(SearchMan.createReadStreamForMember(getVolumeName(1)));
+			file.reset(_archive->createReadStreamForMember(getVolumeName(1)));
 		}
 	} else {
 		file.reset(new Common::File());
@@ -359,8 +359,8 @@ SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Path &
 	}
 
 	ScopedPtr<SeekableReadStream> stream;
-	if (_useSearchMan) {
-		stream.reset(SearchMan.createReadStreamForMember(getVolumeName((entry.volume))));
+	if (_archive) {
+		stream.reset(_archive->createReadStreamForMember(getVolumeName((entry.volume))));
 	} else {
 		stream.reset(new Common::File());
 		if (!((Common::File *)stream.get())->open(Common::FSNode(getVolumeName((entry.volume))))) {
@@ -387,8 +387,8 @@ SeekableReadStream *InstallShieldCabinet::createReadStreamForMember(const Path &
 
 		// Then, iterate through the next volumes until we've read all the data for the file
 		while (bytesRead < entry.compressedSize) {
-			if (_useSearchMan) {
-				stream.reset(SearchMan.createReadStreamForMember(getVolumeName((++volume))));
+			if (_archive) {
+				stream.reset(_archive->createReadStreamForMember(getVolumeName((++volume))));
 			} else {
 				if (!((Common::File *)stream.get())->open(Common::FSNode(getVolumeName((++volume))))) {
 					stream.reset(nullptr);
@@ -510,8 +510,12 @@ Path InstallShieldCabinet::getVolumeName(uint volume) const {
 } // End of anonymous namespace
 
 Archive *makeInstallShieldArchive(const Path &baseName) {
+	return makeInstallShieldArchive(baseName, SearchMan);
+}
+
+Archive *makeInstallShieldArchive(const Common::Path &baseName, Common::Archive &archive) {
 	InstallShieldCabinet *cab = new InstallShieldCabinet();
-	if (!cab->open(&baseName, nullptr)) {
+	if (!cab->open(&baseName, &archive, nullptr)) {
 		delete cab;
 		return nullptr;
 	}
@@ -521,7 +525,7 @@ Archive *makeInstallShieldArchive(const Path &baseName) {
 
 Archive *makeInstallShieldArchive(const FSNode &baseName) {
 	InstallShieldCabinet *cab = new InstallShieldCabinet();
-	if (!cab->open(nullptr, &baseName)) {
+	if (!cab->open(nullptr, nullptr, &baseName)) {
 		delete cab;
 		return nullptr;
 	}
diff --git a/common/compression/installshield_cab.h b/common/compression/installshield_cab.h
index b6ef5dcb82f..8bd83f2735c 100644
--- a/common/compression/installshield_cab.h
+++ b/common/compression/installshield_cab.h
@@ -51,6 +51,17 @@ class SeekableReadStream;
  */
 Archive *makeInstallShieldArchive(const Common::Path &baseName);
 
+/**
+ * This factory method creates an Archive instance corresponding to the content
+ * of the single- or multi-file InstallShield cabinet with the given base name
+ * in a specified archive.
+ *
+ * May return nullptr in case of a failure.
+ *
+ * @param baseName The base filename, e.g. the "data" in "data1.cab"
+ */
+Archive *makeInstallShieldArchive(const Common::Path &baseName, Common::Archive &archive);
+
 /**
  * This factory method creates an Archive instance corresponding to the content
  * of the single- or multi-file InstallShield cabinet with the given base name


Commit: 077d4121a18d3885713ceab3609a43dd527f526b
    https://github.com/scummvm/scummvm/commit/077d4121a18d3885713ceab3609a43dd527f526b
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2023-12-29T11:15:17+02:00

Commit Message:
MTROPOLIS: Add InstallShield cab archive type

Changed paths:
    engines/mtropolis/boot.cpp


diff --git a/engines/mtropolis/boot.cpp b/engines/mtropolis/boot.cpp
index ac5697d4a9a..1e662b8fc6f 100644
--- a/engines/mtropolis/boot.cpp
+++ b/engines/mtropolis/boot.cpp
@@ -27,6 +27,7 @@
 #include "common/compression/vise.h"
 #include "common/formats/winexe.h"
 #include "common/compression/installshieldv3_archive.h"
+#include "common/compression/installshield_cab.h"
 
 #include "graphics/maccursor.h"
 #include "graphics/wincursor.h"
@@ -1118,6 +1119,7 @@ private:
 		kArchiveTypeMacVISE,
 		kArchiveTypeStuffIt,
 		kArchiveTypeInstallShieldV3,
+		kArchiveTypeInstallShieldCab,
 	};
 
 	struct EnumBinding {
@@ -1184,13 +1186,17 @@ void BootScriptContext::addArchive(ArchiveType archiveType, const Common::String
 
 			Common::SeekableReadStream *stream = nullptr;
 
-			if (_isMac)
-				stream = Common::MacResManager::openFileOrDataFork(path, *junction._archive);
-			else
-				stream = junction._archive->createReadStreamForMember(path);
+			bool isSingleStreamArchive = (archiveType != kArchiveTypeInstallShieldCab);
 
-			if (!stream)
-				error("Couldn't mount archive from path %s", archivePath.c_str());
+			if (isSingleStreamArchive) {
+				if (_isMac)
+					stream = Common::MacResManager::openFileOrDataFork(path, *junction._archive);
+				else
+					stream = junction._archive->createReadStreamForMember(path);
+
+				if (!stream)
+					error("Couldn't mount archive from path %s", archivePath.c_str());
+			}
 
 			Common::Archive *archive = nullptr;
 
@@ -1204,6 +1210,10 @@ void BootScriptContext::addArchive(ArchiveType archiveType, const Common::String
 						archive = isa;
 				}
 				break;
+			case kArchiveTypeInstallShieldCab: {
+					archive = Common::makeInstallShieldArchive(path, *junction._archive);
+				}
+				break;
 			case kArchiveTypeStuffIt:
 				archive = Common::createStuffItArchive(stream, false);
 				break;
@@ -1420,7 +1430,8 @@ void BootScriptContext::executeFunction(const Common::String &functionName, cons
 
 	const EnumBinding archiveTypeEnum[] = {ENUM_BINDING(kArchiveTypeMacVISE),
 										   ENUM_BINDING(kArchiveTypeStuffIt),
-										   ENUM_BINDING(kArchiveTypeInstallShieldV3)};
+										   ENUM_BINDING(kArchiveTypeInstallShieldV3),
+										   ENUM_BINDING(kArchiveTypeInstallShieldCab)};
 
 
 	Common::String str1, str2, str3, str4;




More information about the Scummvm-git-logs mailing list