[Scummvm-git-logs] scummvm master -> 2ca39a074565f5904687cbf2d0cb3bfccac3b7db
sev-
noreply at scummvm.org
Fri Dec 16 21:59:38 UTC 2022
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:
0979c692de COMMON: Add new method joinComponents
2ca39a0745 COMMON: Support resource fork coming from OSX zip or FAT
Commit: 0979c692de31f60fc9f6bafffa1c65336d28f706
https://github.com/scummvm/scummvm/commit/0979c692de31f60fc9f6bafffa1c65336d28f706
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-16T22:59:34+01:00
Commit Message:
COMMON: Add new method joinComponents
Changed paths:
common/path.cpp
common/path.h
diff --git a/common/path.cpp b/common/path.cpp
index daaac85f3c6..7adb03e01b3 100644
--- a/common/path.cpp
+++ b/common/path.cpp
@@ -276,6 +276,20 @@ Path Path::punycodeDecode() const {
return ret;
}
+Path Path::joinComponents(const StringArray& c) {
+ String res;
+
+ for (uint i = 0; i < c.size(); i++) {
+ res += c[i];
+ if (i + 1 < c.size())
+ res += DIR_SEPARATOR;
+ }
+
+ Path ret;
+ ret._str = res;
+ return ret;
+}
+
// See getIdentifierString() for more details.
// This does the same but for a single path component and is used by
// getIdentifierString().
diff --git a/common/path.h b/common/path.h
index 8145bd2d6ac..3d3a5f087e3 100644
--- a/common/path.h
+++ b/common/path.h
@@ -215,6 +215,12 @@ public:
* 2 separots follow each other
*/
StringArray splitComponents() const;
+
+
+ /**
+ * Opposite of splitComponents
+ */
+ static Path joinComponents(const StringArray& c);
};
/** @} */
Commit: 2ca39a074565f5904687cbf2d0cb3bfccac3b7db
https://github.com/scummvm/scummvm/commit/2ca39a074565f5904687cbf2d0cb3bfccac3b7db
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2022-12-16T22:59:34+01:00
Commit Message:
COMMON: Support resource fork coming from OSX zip or FAT
Changed paths:
common/macresman.cpp
common/macresman.h
diff --git a/common/macresman.cpp b/common/macresman.cpp
index 4cf244d9d8e..cf7d401fef3 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -168,6 +168,53 @@ bool MacResManager::open(const Path &fileName) {
return open(fileName, SearchMan);
}
+SeekableReadStream *MacResManager::openAppleDoubleWithAppleOrOSXNaming(Archive& archive, const Path &fileName) {
+ SeekableReadStream *stream = archive.createReadStreamForMember(constructAppleDoubleName(fileName));
+ if (stream)
+ return stream;
+
+ const ArchiveMemberPtr archiveMember = archive.getMember(fileName);
+ const Common::FSNode *plainFsNode = dynamic_cast<const Common::FSNode *>(archiveMember.get());
+
+ // Try finding __MACOSX
+ Common::StringArray components = (plainFsNode ? Common::Path(plainFsNode->getPath(), '/') : fileName).splitComponents();
+ if (components.empty() || components[components.size() - 1].empty())
+ return nullptr;
+ for (int i = components.size() - 1; i >= 0; i--) {
+ Common::StringArray newComponents;
+ int j;
+ for (j = 0; j < i; j++)
+ newComponents.push_back(components[j]);
+ newComponents.push_back("__MACOSX");
+ for (; j < (int) components.size() - 1; j++)
+ newComponents.push_back(components[j]);
+ newComponents.push_back("._" + components[(int) components.size() - 1]);
+
+ Common::Path newPath = Common::Path::joinComponents(newComponents);
+ stream = archive.createReadStreamForMember(newPath);
+
+ if (!stream) {
+ Common::FSNode *fsn = new Common::FSNode(newPath);
+ if (fsn && fsn->exists())
+ stream = fsn->createReadStream();
+ else
+ delete fsn;
+ }
+
+ if (stream) {
+ bool appleDouble = (stream->readUint32BE() == 0x00051607);
+ stream->seek(0);
+
+ if (appleDouble) {
+ return stream;
+ }
+ }
+ delete stream;
+ }
+
+ return nullptr;
+}
+
bool MacResManager::open(const Path &fileName, Archive &archive) {
close();
@@ -219,7 +266,7 @@ bool MacResManager::open(const Path &fileName, Archive &archive) {
delete stream;
// Then try for AppleDouble using Apple's naming
- stream = archive.createReadStreamForMember(constructAppleDoubleName(fileName));
+ stream = openAppleDoubleWithAppleOrOSXNaming(archive, fileName);
if (stream && loadFromAppleDouble(stream)) {
_baseFileName = fileName;
return true;
@@ -356,7 +403,7 @@ bool MacResManager::getFileFinderInfo(const Path &fileName, Archive &archive, Ma
// Try for AppleDouble using Apple's naming
stream.reset();
- stream.reset(archive.createReadStreamForMember(constructAppleDoubleName(fileName)));
+ stream.reset(openAppleDoubleWithAppleOrOSXNaming(archive, fileName));
if (stream && getFinderInfoFromAppleDouble(stream.get(), outFinderInfo, outFinderExtendedInfo))
return true;
diff --git a/common/macresman.h b/common/macresman.h
index d66bbed948a..8c8386f90b1 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -318,6 +318,8 @@ private:
static Path constructAppleDoubleName(Path name);
static Path disassembleAppleDoubleName(Path name, bool *isAppleDouble);
+ static SeekableReadStream *openAppleDoubleWithAppleOrOSXNaming(Archive& archive, const Path &fileName);
+
/**
* Do a sanity check whether the given stream is a raw resource fork.
*
More information about the Scummvm-git-logs
mailing list