aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2008-09-27 18:32:01 +0000
committerMax Horn2008-09-27 18:32:01 +0000
commit479e67f2f27f49ae7665cd552acfb55e6192f1ae (patch)
tree006e8358e2009d7c61efcba93ae68024f113a059
parent3779fc2170d93514735b18f876f39aaf4985b9f0 (diff)
downloadscummvm-rg350-479e67f2f27f49ae7665cd552acfb55e6192f1ae.tar.gz
scummvm-rg350-479e67f2f27f49ae7665cd552acfb55e6192f1ae.tar.bz2
scummvm-rg350-479e67f2f27f49ae7665cd552acfb55e6192f1ae.zip
Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority)
svn-id: r34659
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/platform/sdl/sdl.h2
-rw-r--r--common/archive.cpp19
-rw-r--r--common/archive.h14
-rw-r--r--common/system.h2
5 files changed, 29 insertions, 10 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 9a6f294a55..0550017555 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -275,7 +275,7 @@ FilesystemFactory *OSystem_SDL::getFilesystemFactory() {
return _fsFactory;
}
-void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, uint priority) {
+void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
#ifdef DATA_PATH
// Add the global DATA_PATH to the directory search list
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 1cc0acbc29..602cf8d24d 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -209,7 +209,7 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual FilesystemFactory *getFilesystemFactory();
- virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0);
+ virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
virtual Common::SeekableReadStream *openConfigFileForReading();
virtual Common::WriteStream *openConfigFileForWriting();
diff --git a/common/archive.cpp b/common/archive.cpp
index 7e17fdca32..bae316d5e5 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -26,6 +26,7 @@
#include "common/archive.h"
#include "common/fs.h"
#include "common/util.h"
+#include "common/system.h"
namespace Common {
@@ -231,7 +232,7 @@ void SearchSet::insert(const Node &node) {
_list.insert(it, node);
}
-void SearchSet::add(const String& name, ArchivePtr archive, uint priority) {
+void SearchSet::add(const String& name, ArchivePtr archive, int priority) {
if (find(name) == _list.end()) {
Node node = { priority, name, archive };
insert(node);
@@ -256,7 +257,7 @@ void SearchSet::clear() {
_list.clear();
}
-void SearchSet::setPriority(const String& name, uint priority) {
+void SearchSet::setPriority(const String& name, int priority) {
ArchiveList::iterator it = find(name);
if (it == _list.end()) {
warning("SearchSet::setPriority: archive '%s' is not present", name.c_str());
@@ -328,6 +329,10 @@ SeekableReadStream *SearchSet::openFile(const String &name) {
DECLARE_SINGLETON(SearchManager);
+SearchManager::SearchManager() {
+ clear(); // Force a reset
+}
+
void SearchManager::addArchive(const String &name, ArchivePtr archive) {
add(name, archive);
}
@@ -337,8 +342,16 @@ void SearchManager::addDirectory(const String &name, const String &directory) {
}
void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth) {
- add(name, SharedPtr<FSDirectory>(new FSDirectory(directory, depth)));
+ add(name, ArchivePtr(new FSDirectory(directory, depth)));
}
+void SearchManager::clear() {
+ SearchSet::clear();
+
+ // Always keep system specific archives in the SearchManager.
+ // But we give them a lower priority than the default priority (which is 0),
+ // so that archives added by client code are searched first.
+ g_system->addSysArchivesToSearchSet(*this, -1);
+}
} // namespace Common
diff --git a/common/archive.h b/common/archive.h
index 89ea6a5ce2..0b94858826 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -153,7 +153,7 @@ public:
*/
class SearchSet : public Archive {
struct Node {
- uint _priority;
+ int _priority;
String _name;
ArchivePtr _arc;
};
@@ -169,7 +169,7 @@ public:
/**
* Add a new archive to the searchable set.
*/
- void add(const String& name, ArchivePtr archive, uint priority = 0);
+ void add(const String& name, ArchivePtr archive, int priority = 0);
/**
* Remove an archive from the searchable set.
@@ -184,12 +184,12 @@ public:
/**
* Empties the searchable set.
*/
- void clear();
+ virtual void clear();
/**
* Change the order of searches.
*/
- void setPriority(const String& name, uint priority);
+ void setPriority(const String& name, int priority);
virtual bool hasFile(const String &name);
virtual int matchPattern(StringList &list, const String &pattern);
@@ -205,6 +205,8 @@ public:
class SearchManager : public Singleton<SearchManager>, public SearchSet {
public:
+ SearchManager();
+
/**
* Add an existing Archive. This is meant to support searching in system-specific
* archives, namely the MACOSX/IPHONE bundles.
@@ -221,6 +223,10 @@ public:
*/
void addDirectoryRecursive(const String &name, const String &directory, int depth = 4);
+ /**
+ * TODO
+ */
+ virtual void clear();
};
/** Shortcut for accessing the search manager. */
diff --git a/common/system.h b/common/system.h
index cb9dbedad7..176e53ddb4 100644
--- a/common/system.h
+++ b/common/system.h
@@ -917,7 +917,7 @@ public:
* @param s the SearchSet to which the system specific dirs, if any, are added
* @param priority the priority with which those dirs are added
*/
- virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0) {}
+ virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {}
/**
* Open the default config file for reading, by returning a suitable