aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMatthew Hoops2012-03-08 08:02:06 -0500
committerMatthew Hoops2012-03-08 08:02:06 -0500
commit1e734ab48caa842335d0283443614c8dd3f2750a (patch)
treea0d3f6f0d12ac83976891fc9209f4ae2ca2fc8c0 /common
parent7cb82f5e126bd2e3a14ab30d86df35be5c236ba5 (diff)
downloadscummvm-rg350-1e734ab48caa842335d0283443614c8dd3f2750a.tar.gz
scummvm-rg350-1e734ab48caa842335d0283443614c8dd3f2750a.tar.bz2
scummvm-rg350-1e734ab48caa842335d0283443614c8dd3f2750a.zip
COMMON: Add an exists function to MacResManager
Diffstat (limited to 'common')
-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();