aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/macresman.cpp21
-rw-r--r--common/macresman.h7
2 files changed, 28 insertions, 0 deletions
diff --git a/common/macresman.cpp b/common/macresman.cpp
index 1317600cb7..14bdfa7080 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -238,6 +238,27 @@ bool MacResManager::open(FSNode path, String filename) {
return false;
}
+bool MacResManager::exists(const String &filename) {
+ // Try the file name by itself
+ if (Common::File::exists(filename))
+ return true;
+
+ // Try the .rsrc extension
+ if (Common::File::exists(filename + ".rsrc"))
+ return true;
+
+ // Check if we have a MacBinary file
+ Common::File tempFile;
+ if (tempFile.open(filename + ".bin") && isMacBinary(tempFile))
+ return true;
+
+ // Check if we have an AppleDouble file
+ if (tempFile.open("._" + filename) && tempFile.readUint32BE() == 0x00051607)
+ return true;
+
+ return false;
+}
+
bool MacResManager::loadFromAppleDouble(SeekableReadStream &stream) {
if (stream.readUint32BE() != 0x00051607) // tag
return false;
diff --git a/common/macresman.h b/common/macresman.h
index 4d86e46d11..6820106925 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -69,6 +69,13 @@ public:
bool open(FSNode path, String filename);
/**
+ * See if a Mac data/resource fork pair exists.
+ * @param filename The base file name of the file
+ * @return True if either a data fork or resource fork with this name exists
+ */
+ static bool exists(const String &filename);
+
+ /**
* Close the Mac data/resource fork pair.
*/
void close();