diff options
author | Matthew Hoops | 2012-04-07 21:19:11 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-04-07 21:19:11 -0400 |
commit | 5dfa4333d1a566f064101ca505cd15c77e3c86c0 (patch) | |
tree | d4e25264361f66405f0c6903500ea167b8d737b4 | |
parent | 1fb5238cf32a1fea07e26ba3693c7d6c97dd9023 (diff) | |
download | scummvm-rg350-5dfa4333d1a566f064101ca505cd15c77e3c86c0.tar.gz scummvm-rg350-5dfa4333d1a566f064101ca505cd15c77e3c86c0.tar.bz2 scummvm-rg350-5dfa4333d1a566f064101ca505cd15c77e3c86c0.zip |
COMMON: Hopefully fix AppleDouble files with directories
-rw-r--r-- | common/macresman.cpp | 22 | ||||
-rw-r--r-- | common/macresman.h | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/common/macresman.cpp b/common/macresman.cpp index 14bdfa7080..f2f020c6de 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -124,7 +124,7 @@ bool MacResManager::open(String filename) { File *file = new File(); // First, let's try to see if the Mac converted name exists - if (file->open("._" + filename) && loadFromAppleDouble(*file)) { + if (file->open(constructAppleDoubleName(filename)) && loadFromAppleDouble(*file)) { _baseFileName = filename; return true; } @@ -185,7 +185,7 @@ bool MacResManager::open(FSNode path, String filename) { #endif // First, let's try to see if the Mac converted name exists - FSNode fsNode = path.getChild("._" + filename); + FSNode fsNode = path.getChild(constructAppleDoubleName(filename)); if (fsNode.exists() && !fsNode.isDirectory()) { SeekableReadStream *stream = fsNode.createReadStream(); if (loadFromAppleDouble(*stream)) { @@ -253,7 +253,7 @@ bool MacResManager::exists(const String &filename) { return true; // Check if we have an AppleDouble file - if (tempFile.open("._" + filename) && tempFile.readUint32BE() == 0x00051607) + if (tempFile.open(constructAppleDoubleName(filename)) && tempFile.readUint32BE() == 0x00051607) return true; return false; @@ -574,4 +574,20 @@ void MacResManager::readMap() { } } +Common::String MacResManager::constructAppleDoubleName(Common::String name) { + // Insert "._" before the last portion of a path name + for (int i = name.size() - 1; i >= 0; i--) { + if (i == 0) { + name.insertChar('_', 0); + name.insertChar('.', 0); + } else if (name[i] == '/') { + name.insertChar('_', i + 1); + name.insertChar('.', i + 1); + break; + } + } + + return name; +} + } // End of namespace Common diff --git a/common/macresman.h b/common/macresman.h index 6820106925..f334405664 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -175,6 +175,8 @@ private: bool loadFromMacBinary(SeekableReadStream &stream); bool loadFromAppleDouble(SeekableReadStream &stream); + static Common::String constructAppleDoubleName(Common::String name); + enum { kResForkNone = 0, kResForkRaw, |