aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/detection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/detection.cpp')
-rw-r--r--engines/scumm/detection.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index d3397fe208..0a54f2d29b 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -25,6 +25,7 @@
#include "base/plugins.h"
+#include "common/archive.h"
#include "common/config-manager.h"
#include "common/fs.h"
#include "common/list.h"
@@ -177,7 +178,7 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename
}
struct DetectorDesc {
- Common::FilesystemNode node;
+ Common::FSNode node;
Common::String md5;
const MD5Table *md5Entry; // Entry of the md5 table corresponding to this file, if any.
};
@@ -191,7 +192,7 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com
// when performing the matching. The first match is returned, so if you
// search for "resource" and two nodes "RESOURE and "resource" are present,
// the first match is used.
-static bool searchFSNode(const Common::FSList &fslist, const Common::String &name, Common::FilesystemNode &result) {
+static bool searchFSNode(const Common::FSList &fslist, const Common::String &name, Common::FSNode &result) {
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (!scumm_stricmp(file->getName().c_str(), name.c_str())) {
result = *file;
@@ -211,21 +212,23 @@ static Common::Language detectLanguage(const Common::FSList &fslist, byte id) {
// ever determine that this is insufficient, we can still
// switch to MD5 based detection).
const char *filename = (id == GID_CMI) ? "LANGUAGE.TAB" : "LANGUAGE.BND";
- Common::File tmp;
- Common::FilesystemNode langFile;
- if (!searchFSNode(fslist, filename, langFile) || !tmp.open(langFile)) {
+ Common::FilePtr tmp;
+ Common::FSNode langFile;
+ if (searchFSNode(fslist, filename, langFile))
+ tmp = Common::FilePtr(langFile.openForReading());
+ if (!tmp) {
// try loading in RESOURCE sub dir...
- Common::FilesystemNode resDir;
+ Common::FSNode resDir;
Common::FSList tmpList;
if (searchFSNode(fslist, "RESOURCE", resDir)
&& resDir.isDirectory()
- && resDir.getChildren(tmpList, Common::FilesystemNode::kListFilesOnly)
+ && resDir.getChildren(tmpList, Common::FSNode::kListFilesOnly)
&& searchFSNode(tmpList, filename, langFile)) {
- tmp.open(langFile);
+ tmp = Common::FilePtr(langFile.openForReading());
}
}
- if (tmp.isOpen()) {
- uint size = tmp.size();
+ if (tmp) {
+ uint size = tmp->size();
if (id == GID_CMI) {
switch (size) {
case 439080: // 2daf3db71d23d99d19fc9a544fcf6431
@@ -450,8 +453,8 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com
// To do this, we take a close look at the detection file and
// try to filter out some cases.
- Common::File tmp;
- if (!tmp.open(d.node)) {
+ Common::FilePtr tmp(d.node.openForReading());
+ if (!tmp) {
warning("SCUMM testGame: failed to open '%s' for read access", d.node.getPath().c_str());
return false;
}
@@ -465,7 +468,7 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com
// Read a few bytes to narrow down the game.
byte buf[6];
- tmp.read(buf, 6);
+ tmp->read(buf, 6);
if (buf[0] == 0xbc && buf[1] == 0xb9) {
// The NES version of MM
@@ -784,8 +787,8 @@ PluginError ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
// Fetch the list of files in the current directory
Common::FSList fslist;
- Common::FilesystemNode dir(ConfMan.get("path"));
- if (!dir.getChildren(fslist, Common::FilesystemNode::kListFilesOnly)) {
+ Common::FSNode dir(ConfMan.get("path"));
+ if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) {
return kInvalidPathError;
}