From c549a0e708f297f9724b55ad6d72ba32a60f6bbd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 27 Sep 2008 23:00:46 +0000 Subject: Changed Common::File to use SearchMan svn-id: r34663 --- common/file.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'common/file.cpp') diff --git a/common/file.cpp b/common/file.cpp index cf396a32cd..0ddeb93324 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -31,9 +31,6 @@ namespace Common { -static Common::SearchSet *s_searchSet = 0; - - void File::addDefaultDirectory(const String &directory) { FilesystemNode dir(directory); addDefaultDirectoryRecursive(dir, 1); @@ -52,18 +49,12 @@ void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level) { if (level <= 0 || !dir.exists() || !dir.isDirectory()) return; - if (!s_searchSet) { - s_searchSet = new Common::SearchSet(); - g_system->addSysArchivesToSearchSet(*s_searchSet); - } - Common::ArchivePtr dataArchive(new Common::FSDirectory(dir, level)); - s_searchSet->add(dir.getPath(), dataArchive, 1); + SearchMan.add(dir.getPath(), dataArchive); } void File::resetDefaultDirectories() { - delete s_searchSet; - s_searchSet = 0; + SearchMan.clear(); } File::File() @@ -82,14 +73,14 @@ bool File::open(const String &filename) { _name.clear(); clearIOFailed(); - if (s_searchSet && s_searchSet->hasFile(filename)) { + if (SearchMan.hasFile(filename)) { debug(3, "Opening hashed: %s", filename.c_str()); - _handle = s_searchSet->openFile(filename); - } else if (s_searchSet && s_searchSet->hasFile(filename + ".")) { + _handle = SearchMan.openFile(filename); + } else if (SearchMan.hasFile(filename + ".")) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) debug(3, "Opening hashed: %s.", filename.c_str()); - _handle = s_searchSet->openFile(filename); + _handle = SearchMan.openFile(filename); } else { // Last resort: try the current directory FilesystemNode file(filename); @@ -135,9 +126,9 @@ bool File::open(const FilesystemNode &node) { } bool File::exists(const String &filename) { - if (s_searchSet && s_searchSet->hasFile(filename)) { + if (SearchMan.hasFile(filename)) { return true; - } else if (s_searchSet && s_searchSet->hasFile(filename + ".")) { + } else if (SearchMan.hasFile(filename + ".")) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) return true; -- cgit v1.2.3 From a4292055f7d5d058a71c69c53f62330f906fdda7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 29 Sep 2008 10:32:06 +0000 Subject: File::open no longer falls back to searching the current dir (if this causes any regressions, please report them; don't work around them, don't revert this change, without discussing it first) svn-id: r34680 --- common/file.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'common/file.cpp') diff --git a/common/file.cpp b/common/file.cpp index 0ddeb93324..6558dfea33 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -80,16 +80,11 @@ bool File::open(const String &filename) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) debug(3, "Opening hashed: %s.", filename.c_str()); - _handle = SearchMan.openFile(filename); - } else { - // Last resort: try the current directory - FilesystemNode file(filename); - if (file.exists() && !file.isDirectory()) - _handle = file.openForReading(); + _handle = SearchMan.openFile(filename + "."); } if (_handle == NULL) - debug(2, "File %s not opened", filename.c_str()); + debug(2, "File::open: '%s' not found", filename.c_str()); else _name = filename; @@ -118,7 +113,7 @@ bool File::open(const FilesystemNode &node) { _handle = node.openForReading(); if (_handle == NULL) - debug(2, "File %s not found", filename.c_str()); + debug(2, "File::open: '%s' not found", node.getPath().c_str()); else _name = filename; @@ -132,11 +127,6 @@ bool File::exists(const String &filename) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) return true; - } else { - // Last resort: try the current directory - FilesystemNode file(filename); - if (file.exists() && !file.isDirectory()) - return true; } return false; -- cgit v1.2.3