[Scummvm-git-logs] scummvm master -> 64cd45c30edccd34f36619eece7dbe41ca5fb812

sev- noreply at scummvm.org
Sun Nov 20 16:21:48 UTC 2022


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

Summary:
98f178c58f DETECTOR: Allow detecting with MacBinary with no resource fork
c92ec629db COMMON: Convenience function for retrieving data fork
64cd45c30e HADESCH: Support files in MacBinary format


Commit: 98f178c58f81e0e9aca5d967cb774cdd522fb5ba
    https://github.com/scummvm/scummvm/commit/98f178c58f81e0e9aca5d967cb774cdd522fb5ba
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-11-20T17:21:44+01:00

Commit Message:
DETECTOR: Allow detecting with MacBinary with no resource fork

Changed paths:
    common/macresman.cpp
    engines/advancedDetector.cpp


diff --git a/common/macresman.cpp b/common/macresman.cpp
index d7d4ce8481f..2a3074149fc 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -133,7 +133,7 @@ bool MacResManager::hasDataFork() const {
 }
 
 bool MacResManager::hasResFork() const {
-	return !_baseFileName.empty() && _mode != kResForkNone;
+	return !_baseFileName.empty() && _mode != kResForkNone && _resForkSize != 0;
 }
 
 uint32 MacResManager::getResForkDataSize() const {
@@ -446,13 +446,15 @@ bool MacResManager::loadFromMacBinary(SeekableReadStream *stream) {
 			_resForkOffset = MBI_INFOHDR + dataSizePad;
 			_resForkSize = rsrcSize;
 		}
-	}
 
-	if (_resForkOffset < 0)
-		return false;
+		if (_resForkOffset < 0)
+			return false;
 
-	_mode = kResForkMacBinary;
-	return load(stream);
+		_mode = kResForkMacBinary;
+		return load(stream);
+	}
+
+	return false;
 }
 
 bool MacResManager::loadFromRawFork(SeekableReadStream *stream) {
@@ -472,6 +474,11 @@ bool MacResManager::load(SeekableReadStream *stream) {
 	if (_mode == kResForkNone)
 		return false;
 
+	if (_resForkSize == 0) {
+		_stream = stream;
+		return true;
+	}
+
 	stream->seek(_resForkOffset);
 
 	_dataOffset = stream->readUint32BE() + _resForkOffset;
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 7b915a8636b..dc99a8eb0c3 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -557,6 +557,15 @@ static bool getFilePropertiesIntern(uint md5Bytes, const AdvancedMetaEngine::Fil
 
 		if (fileProps.size != 0)
 			return true;
+
+		Common::SeekableReadStream *dataFork = macResMan.getDataFork();
+		if (dataFork && dataFork->size()) {
+			fileProps.size = dataFork->size();
+			fileProps.md5 = Common::computeStreamMD5AsString(*dataFork, md5Bytes);
+			delete dataFork;
+			return true;
+		}
+		delete dataFork;
 	}
 
 	if (!allFiles.contains(fname))


Commit: c92ec629dbf800e7069036bf16b3809e51e67da4
    https://github.com/scummvm/scummvm/commit/c92ec629dbf800e7069036bf16b3809e51e67da4
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-11-20T17:21:44+01:00

Commit Message:
COMMON: Convenience function for retrieving data fork

Changed paths:
    common/macresman.cpp
    common/macresman.h


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 2a3074149fc..5f48120b2f6 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -253,6 +253,37 @@ bool MacResManager::open(const Path &fileName, Archive &archive) {
 	return false;
 }
 
+SeekableReadStream * MacResManager::openFileOrDataFork(const Path &fileName) {
+	return openFileOrDataFork(fileName, SearchMan);
+}
+
+SeekableReadStream * MacResManager::openFileOrDataFork(const Path &fileName, Archive &archive) {
+	SeekableReadStream *stream = archive.createReadStreamForMember(fileName);
+	// Check the basename for Macbinary
+	if (stream && isMacBinary(*stream)) {
+		stream->seek(MBI_DFLEN);
+		uint32 dataSize = stream->readUint32BE();
+		return new SeekableSubReadStream(stream, MBI_INFOHDR, MBI_INFOHDR + dataSize, DisposeAfterUse::YES);
+	}
+	// All formats other than Macbinary and AppleSingle (not supported) use
+	// basename-named file as data fork holder.
+	if (stream)
+		return stream;
+
+	// Check .bin for MacBinary next
+	stream = archive.createReadStreamForMember(fileName.append(".bin"));
+	if (stream && isMacBinary(*stream)) {
+		stream->seek(MBI_DFLEN);
+		uint32 dataSize = stream->readUint32BE();
+		return new SeekableSubReadStream(stream, MBI_INFOHDR, MBI_INFOHDR + dataSize, DisposeAfterUse::YES);
+	}
+	delete stream;
+
+	// The file doesn't exist
+	return nullptr;
+}
+
+
 bool MacResManager::exists(const Path &fileName) {
 	// Try the file name by itself
 	if (File::exists(fileName))
diff --git a/common/macresman.h b/common/macresman.h
index 9b858a25269..34f785a9bd4 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -152,6 +152,13 @@ public:
 	 */
 	bool open(const Path &fileName, Archive &archive);
 
+	/**
+	 * Opens file named fileName or data fork extracted as macbin
+	 * @return The stream if found, 0 otherwise
+	 */
+	static SeekableReadStream *openFileOrDataFork(const Path &fileName, Archive &archive);
+	static SeekableReadStream *openFileOrDataFork(const Path &fileName);
+
 	/**
 	 * See if a Mac data/resource fork pair exists.
 	 * @param fileName The base file name of the file


Commit: 64cd45c30edccd34f36619eece7dbe41ca5fb812
    https://github.com/scummvm/scummvm/commit/64cd45c30edccd34f36619eece7dbe41ca5fb812
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-11-20T17:21:44+01:00

Commit Message:
HADESCH: Support files in MacBinary format

Changed paths:
    engines/hadesch/hadesch.cpp
    engines/hadesch/pod_file.cpp
    engines/hadesch/video.cpp


diff --git a/engines/hadesch/hadesch.cpp b/engines/hadesch/hadesch.cpp
index 483c5d397ad..1fa7c88ac77 100644
--- a/engines/hadesch/hadesch.cpp
+++ b/engines/hadesch/hadesch.cpp
@@ -490,10 +490,10 @@ Common::Error HadeschEngine::run() {
 		};
 		debug("HadeschEngine: loading wd.pod");
 		for (uint i = 0; i < ARRAYSIZE(wdpodpaths); ++i) {
-			Common::SharedPtr<Common::File> file(new Common::File());
-			if (file->open(wdpodpaths[i])) {
+			Common::SharedPtr<Common::SeekableReadStream> stream(Common::MacResManager::openFileOrDataFork(wdpodpaths[i]));
+			if (stream) {
 				_wdPodFile = Common::SharedPtr<PodFile>(new PodFile("WD.POD"));
-				_wdPodFile->openStore(file);
+				_wdPodFile->openStore(stream);
 				break;
 			}
 		}
@@ -511,8 +511,8 @@ Common::Error HadeschEngine::run() {
 	// on cdScenePath
 	const char *const scenepaths[] = {"CDAssets/", "Scenes/"};
 	for (uint i = 0; i < ARRAYSIZE(scenepaths); ++i) {
-		Common::ScopedPtr<Common::File> file(new Common::File());
-		if (file->open(Common::String(scenepaths[i]) + "OLYMPUS/OL.POD")) {
+		Common::ScopedPtr<Common::SeekableReadStream> stream(Common::MacResManager::openFileOrDataFork(Common::String(scenepaths[i]) + "OLYMPUS/OL.POD"));
+		if (stream) {
 			_cdScenesPath = scenepaths[i];
 			break;
 		}
diff --git a/engines/hadesch/pod_file.cpp b/engines/hadesch/pod_file.cpp
index ba58a197d90..461f106d44c 100644
--- a/engines/hadesch/pod_file.cpp
+++ b/engines/hadesch/pod_file.cpp
@@ -22,6 +22,7 @@
  */
 #include "common/debug.h"
 #include "common/file.h"
+#include "common/macresman.h"
 #include "common/memstream.h"
 
 #include "hadesch/hadesch.h"
@@ -75,12 +76,16 @@ bool PodFile::openStore(const Common::SharedPtr<Common::SeekableReadStream> &par
 }
 
 bool PodFile::openStore(const Common::String &name) {
-	Common::SharedPtr<Common::File> file(new Common::File());
-	if (name.empty() || !file->open(name)) {
+  	if (name.empty()) {
 		return false;
 	}
 
-	return openStore(file);
+	Common::SharedPtr<Common::SeekableReadStream> stream(Common::MacResManager::openFileOrDataFork(name));
+	if (!stream) {
+		return false;
+	}
+
+	return openStore(stream);
 }
 
 // It's tempting to use substream but substream is not thread safe
diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp
index 29a2ccb8eae..6fdc6e55f66 100644
--- a/engines/hadesch/video.cpp
+++ b/engines/hadesch/video.cpp
@@ -32,6 +32,7 @@
 #include "hadesch/pod_file.h"
 #include "hadesch/baptr.h"
 #include "common/translation.h"
+#include "common/macresman.h"
 
 static const int kVideoMaxW = 1280;
 static const int kVideoMaxH = 480;
@@ -758,12 +759,13 @@ void VideoRoom::playVideo(const Common::String &name, int zValue,
 	Common::SharedPtr<Video::SmackerDecoder> decoder
 	  = Common::SharedPtr<Video::SmackerDecoder>(new Video::SmackerDecoder());
 
-	Common::File *file = new Common::File;
 	Common::String mappedName = _assetMap.get(name, 1);
 	if (mappedName == "") {
 		mappedName = name;
 	}
-	if (!file->open(_smkPath + "/" + mappedName + ".SMK") || !decoder->loadStream(file)) {
+	Common::SeekableReadStream *stream = Common::MacResManager::openFileOrDataFork(_smkPath + "/" + mappedName + ".SMK");
+
+	if (!stream || !decoder->loadStream(stream)) {
 		debug("Video file %s can't be opened", name.c_str());
 		g_vm->handleEvent(callbackEvent);
 		return;




More information about the Scummvm-git-logs mailing list