From 44a39ffbc66dbc9f019f041a47aaf9ba5a24d19f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 15 Jun 2010 10:59:23 +0000 Subject: AdvancedDetector: Add new parameter directoryGlobs. Without this parameter mass detection gave tons of false alarms. Use globbing for narrowing down the depth search. svn-id: r49788 --- engines/advancedDetector.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines/advancedDetector.cpp') diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index ee0c5c7c62..974970ff0f 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -341,7 +341,7 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParams ¶ms); -static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth) { +static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth, const char **directoryGlobs) { if (depth <= 0) return; @@ -354,10 +354,23 @@ static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, if (file->isDirectory()) { Common::FSList files; + if (!directoryGlobs) + continue; + + bool matched = false; + for (const char *glob = *directoryGlobs; *glob; glob++) + if (file->getName().matchString(glob, true)) { + matched = true; + break; + } + + if (!matched) + continue; + if (!file->getChildren(files, Common::FSNode::kListAll)) continue; - composeFileHashMap(files, allFiles, depth - 1); + composeFileHashMap(files, allFiles, depth - 1, directoryGlobs); } Common::String tstr = file->getName(); @@ -385,7 +398,7 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p // First we compose a hashmap of all files in fslist. // Includes nifty stuff like removing trailing dots and ignoring case. - composeFileHashMap(fslist, allFiles, (params.depth == 0 ? 1 : params.depth)); + composeFileHashMap(fslist, allFiles, (params.depth == 0 ? 1 : params.depth), params.directoryGlobs); // Check which files are included in some ADGameDescription *and* present // in fslist. Compute MD5s and file sizes for these files. -- cgit v1.2.3