aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2008-10-03 14:25:03 +0000
committerMax Horn2008-10-03 14:25:03 +0000
commitfe39d4f5075cc723945ca813142d02983069d0d5 (patch)
tree6954dcb3266d70746a5bdaf1bf24ee205acd1671 /common
parentdf3b8fd14c9ce97fe81976e30086af95000bb2f1 (diff)
parent2219ccf911f3cf9a6d9e5f732e0b6e47d1c8b313 (diff)
downloadscummvm-rg350-fe39d4f5075cc723945ca813142d02983069d0d5.tar.gz
scummvm-rg350-fe39d4f5075cc723945ca813142d02983069d0d5.tar.bz2
scummvm-rg350-fe39d4f5075cc723945ca813142d02983069d0d5.zip
Merged revisions 34656-34661,34663-34664,34671-34672,34674-34676,34678-34686,34688-34689,34691-34698,34700-34705,34707-34713,34715-34722,34725 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk ........ r34656 | eriktorbjorn | 2008-09-27 19:25:40 +0200 (Sa, 27 Sep 2008) | 2 lines Fixed typos. ........ r34657 | eriktorbjorn | 2008-09-27 19:47:22 +0200 (Sa, 27 Sep 2008) | 2 lines Allow quitting or returning to the launcher while cutscenes are playing. ........ r34658 | eriktorbjorn | 2008-09-27 19:51:22 +0200 (Sa, 27 Sep 2008) | 2 lines Slight simplification of last commit. ........ r34659 | fingolfin | 2008-09-27 20:32:01 +0200 (Sa, 27 Sep 2008) | 1 line Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority) ........ r34660 | fingolfin | 2008-09-27 20:34:24 +0200 (Sa, 27 Sep 2008) | 1 line Fixed a nasty bug in SearchManager::addDirectory; made the 'char' constructor of Common::String explicit, to avoid such bugs in the future ........ r34661 | drmccoy | 2008-09-27 22:04:04 +0200 (Sa, 27 Sep 2008) | 2 lines Added a spanish floppy version of Lost in Time, as supplied by goodoldgeorg in bug report #2105220 ........ r34663 | fingolfin | 2008-09-28 01:00:46 +0200 (So, 28 Sep 2008) | 1 line Changed Common::File to use SearchMan ........ r34664 | fingolfin | 2008-09-28 01:27:01 +0200 (So, 28 Sep 2008) | 1 line SCUMM: Use FilesystemNode::openForReading instead of Common::File::open(FilesystemNode) in the detector ........ r34671 | john_doe | 2008-09-28 22:02:01 +0200 (So, 28 Sep 2008) | 1 line Return 32000 in sfGetCdTime instead of 0; this fixes the Manhole intro/credits (until the function is actually implemented) ........ r34672 | sev | 2008-09-28 23:07:41 +0200 (So, 28 Sep 2008) | 2 lines Add Italian C64 Zak ........ r34674 | sev | 2008-09-28 23:53:14 +0200 (So, 28 Sep 2008) | 2 lines Fix bug #2043489: DRASCULA: Cannot disable speech ........ r34675 | sev | 2008-09-29 00:07:16 +0200 (Mo, 29 Sep 2008) | 3 lines - Renamed withVoices to _subtitlesDisabled as it reflect the true meaning. - Allowed to disable subtitles from options dialogs including RTL. ........ r34676 | sev | 2008-09-29 00:19:11 +0200 (Mo, 29 Sep 2008) | 2 lines Use better "silence" without clicks when speech is disabled. ........ r34678 | fingolfin | 2008-09-29 12:29:01 +0200 (Mo, 29 Sep 2008) | 1 line Added FIXME to GP2x port ........ r34679 | fingolfin | 2008-09-29 12:30:31 +0200 (Mo, 29 Sep 2008) | 1 line Add priority parameter to the SearchMan API ........ r34680 | fingolfin | 2008-09-29 12:32:06 +0200 (Mo, 29 Sep 2008) | 1 line 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) ........ r34681 | fingolfin | 2008-09-29 12:49:36 +0200 (Mo, 29 Sep 2008) | 1 line Don't subclass ArjFile from Common::File (there seems to be no good reason for it). BTW, this code is an abomination and should be replaced by an Archive/SearchSet approach ........ r34682 | fingolfin | 2008-09-29 13:01:25 +0200 (Mo, 29 Sep 2008) | 1 line Added const qualifiers ........ r34683 | fingolfin | 2008-09-29 13:02:11 +0200 (Mo, 29 Sep 2008) | 1 line SCUMM HE: Fixed leak in Win32ResExtractor::extractResource_, use _filename instead of File::name ........ r34684 | fingolfin | 2008-09-29 13:03:10 +0200 (Mo, 29 Sep 2008) | 1 line Added const qualifiers ........ r34685 | fingolfin | 2008-09-29 13:07:39 +0200 (Mo, 29 Sep 2008) | 1 line Don't use File::name() needlessly (i.e. if you still know which file you just opened :) ........ r34686 | cyx | 2008-09-29 21:09:56 +0200 (Mo, 29 Sep 2008) | 1 line add constructor to SearchSet::Node for proper init of structure members with gcc 3.4.x (see tracker items #2120595, #2106292) ........ r34688 | cyx | 2008-09-29 22:08:26 +0200 (Mo, 29 Sep 2008) | 1 line restrict _heXmapNum to HE versions, should fix #2135822 ........ r34689 | eriktorbjorn | 2008-09-29 22:40:58 +0200 (Mo, 29 Sep 2008) | 4 lines Since no one has come up with any better suggestion... this should fix #2123258 ("COMI: Crash after video (SAN) play"). The eos() function won't return true until we've tried to read *past* the end of the stream. ........ r34691 | tanoku | 2008-09-30 00:29:07 +0200 (Di, 30 Sep 2008) | 1 line Ported ZipArchive::getAllNames() implementation from GUI branch. ........ r34692 | fingolfin | 2008-09-30 11:07:03 +0200 (Di, 30 Sep 2008) | 1 line Order alphabetically ........ r34693 | fingolfin | 2008-09-30 11:08:17 +0200 (Di, 30 Sep 2008) | 1 line SAGA: Removed patchesCount from SAGAGameDescription ........ r34694 | fingolfin | 2008-09-30 11:09:39 +0200 (Di, 30 Sep 2008) | 1 line SCUMM HE: Use FilesystemNode::openForReading() instead of 'new Common::File' (didn't cover all instances, though) ........ r34695 | fingolfin | 2008-09-30 11:11:25 +0200 (Di, 30 Sep 2008) | 1 line SAGA: Forgot to commit saga.h ........ r34696 | fingolfin | 2008-09-30 11:12:02 +0200 (Di, 30 Sep 2008) | 1 line Added multiple new open() methods to Common::File, which make it possible to use this class as a generic convenience wrapper around all kinds of SeekableReadStream; also renamed the name() method to the less confusing getName() ........ r34697 | fingolfin | 2008-09-30 13:33:43 +0200 (Di, 30 Sep 2008) | 1 line cleanup ........ r34698 | tanoku | 2008-09-30 13:53:37 +0200 (Di, 30 Sep 2008) | 1 line Fixed functionality of ZipArchive::getAllNames(). Now it expects a possibly non-empty string list and returns the amount of new filenames added to it. ........ r34700 | fingolfin | 2008-09-30 14:27:38 +0200 (Di, 30 Sep 2008) | 1 line Renamed Engine::quit to Engine::shouldQuit (previously, it was easily confused with Engine::quitGame); also cleaned up engine.h a bit ........ r34701 | fingolfin | 2008-09-30 14:37:28 +0200 (Di, 30 Sep 2008) | 1 line cleanup ........ r34702 | fingolfin | 2008-09-30 14:38:44 +0200 (Di, 30 Sep 2008) | 1 line AdvancedDetector: Do not (ab)use paths to keep track of files, rather, use FSNodes -- partial (?) fix for bug #2137680 ........ r34703 | fingolfin | 2008-09-30 14:58:27 +0200 (Di, 30 Sep 2008) | 1 line SAGA: Some code cleanup ........ r34704 | fingolfin | 2008-09-30 14:59:29 +0200 (Di, 30 Sep 2008) | 1 line SKY: Fix detector to not (ab)use FSNode::getPath; if you want to open a FSNode, just pass it to File::open ........ r34705 | thebluegr | 2008-09-30 15:19:14 +0200 (Di, 30 Sep 2008) | 1 line Fixed crash when starting IHNM, a regression from commit #34693 ........ r34707 | fingolfin | 2008-09-30 17:42:19 +0200 (Di, 30 Sep 2008) | 1 line Fixing ConfigManager::loadConfigFile ........ r34708 | fingolfin | 2008-09-30 18:23:35 +0200 (Di, 30 Sep 2008) | 1 line AGI: Another case where it is better to use FSNodes directly, instead of converting them to path strings ........ r34709 | fingolfin | 2008-09-30 18:34:38 +0200 (Di, 30 Sep 2008) | 1 line Modified FilePluginProvider to use FSNodes (instead of raw filenames / paths) in its API ........ r34710 | fingolfin | 2008-09-30 18:38:46 +0200 (Di, 30 Sep 2008) | 1 line AGI: Got rid of yet another unwarranted use of FSNode::getPath ........ r34711 | fingolfin | 2008-09-30 18:53:04 +0200 (Di, 30 Sep 2008) | 1 line AGI: Simplify WagFileParser by not reading data into a memory stream first (this was there to improve performance on systems with slow seeking; those systems should use another approach, see scummvm-devel) ........ r34712 | thebluegr | 2008-09-30 18:55:10 +0200 (Di, 30 Sep 2008) | 1 line Fix crash when starting ITE, a regression from commit #34705 ........ r34713 | fingolfin | 2008-09-30 19:09:41 +0200 (Di, 30 Sep 2008) | 1 line Fix ThemeBrowser to use FSNodes, not getPath() ........ r34715 | Kirben | 2008-10-02 16:41:50 +0200 (Do, 02 Okt 2008) | 1 line Correct HE version for Putt-Putt Enters the Race (French/Windows). ........ r34716 | fingolfin | 2008-10-02 18:58:59 +0200 (Do, 02 Okt 2008) | 1 line Renamed FilesystemNode -> FSNode ........ r34717 | fingolfin | 2008-10-02 19:08:15 +0200 (Do, 02 Okt 2008) | 1 line cleanup ........ r34718 | fingolfin | 2008-10-02 19:17:18 +0200 (Do, 02 Okt 2008) | 1 line Ignore String::deleteLastChar when called on an empty string ........ r34719 | fingolfin | 2008-10-02 19:20:21 +0200 (Do, 02 Okt 2008) | 1 line Fix for bug #2142743: Assertion on clicking "Theme" in Options ........ r34720 | fingolfin | 2008-10-02 19:48:01 +0200 (Do, 02 Okt 2008) | 7 lines Engine class changed: - Moved initCommonGFX() && GUIErrorMessage() out of class Engine - got rid of the _autosavePeriod member (this prevented users from changing the autosave period during runtime) - Got rid of an evil 'using GUI::Dialog' statement - Clarified some Doxygen comments ........ r34721 | fingolfin | 2008-10-02 19:52:29 +0200 (Do, 02 Okt 2008) | 1 line Add the current dir to the global SearchSet, i.e. to SearchMan (this should fix the problems on Windows, and maybe other systems, see 'bug' #2137680) ........ r34722 | fingolfin | 2008-10-02 19:55:08 +0200 (Do, 02 Okt 2008) | 1 line Forgot to mention yet another Engine class change: mainMenuDialog -> openMainMenuDialog; and also forgot to commit this related file :/ ........ r34725 | fingolfin | 2008-10-02 20:11:40 +0200 (Do, 02 Okt 2008) | 1 line typo ........ svn-id: r34730
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp15
-rw-r--r--common/archive.cpp57
-rw-r--r--common/archive.h37
-rw-r--r--common/config-manager.cpp3
-rw-r--r--common/file.cpp95
-rw-r--r--common/file.h64
-rw-r--r--common/fs.cpp58
-rw-r--r--common/fs.h35
-rw-r--r--common/md5.cpp10
-rw-r--r--common/md5.h6
-rw-r--r--common/str.cpp3
-rw-r--r--common/str.h2
-rw-r--r--common/system.cpp4
-rw-r--r--common/system.h2
-rw-r--r--common/unarj.cpp6
-rw-r--r--common/unarj.h8
-rw-r--r--common/unzip.cpp19
-rw-r--r--common/unzip.h2
-rw-r--r--common/xmlparser.h2
19 files changed, 248 insertions, 180 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 1b0db4755a..1ec8c47715 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -246,9 +246,9 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c
path = ".";
warning("No path was provided. Assuming the data files are in the current directory");
}
- FilesystemNode dir(path);
+ FSNode dir(path);
FSList files;
- if (!dir.isDirectory() || !dir.getChildren(files, FilesystemNode::kListAll)) {
+ if (!dir.isDirectory() || !dir.getChildren(files, FSNode::kListAll)) {
warning("Game data path does not exist or is not a directory (%s)", path.c_str());
return kNoGameDataFoundError;
}
@@ -290,6 +290,7 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c
typedef HashMap<String, bool, IgnoreCase_Hash, IgnoreCase_EqualTo> StringSet;
typedef HashMap<String, int32, IgnoreCase_Hash, IgnoreCase_EqualTo> IntMap;
+typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> FileMap;
static void reportUnknown(const StringMap &filesMD5, const IntMap &filesSize) {
// TODO: This message should be cleaned up / made more specific.
@@ -307,10 +308,10 @@ static void reportUnknown(const StringMap &filesMD5, const IntMap &filesSize) {
printf("\n");
}
-static ADGameDescList detectGameFilebased(const StringMap &allFiles, const Common::ADParams &params);
+static ADGameDescList detectGameFilebased(const FileMap &allFiles, const Common::ADParams &params);
static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &params, Language language, Platform platform, const Common::String extra) {
- StringMap allFiles;
+ FileMap allFiles;
StringSet detectFiles;
StringMap filesMD5;
@@ -334,7 +335,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p
if (tstr.lastChar() == '.')
tstr.deleteLastChar();
- allFiles[tstr] = file->getPath(); // Record the presence of this file
+ allFiles[tstr] = *file; // Record the presence of this file
}
// Compute the set of files for which we need MD5s for. I.e. files which are
@@ -356,7 +357,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p
debug(3, "+ %s", fname.c_str());
char md5str[32+1];
- if (!md5_file_string(allFiles[fname].c_str(), md5str, params.md5Bytes))
+ if (!md5_file_string(allFiles[fname], md5str, params.md5Bytes))
continue;
filesMD5[fname] = md5str;
@@ -464,7 +465,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p
* the maximal number of matching files. In case of a tie, the entry
* coming first in the list is chosen.
*/
-static ADGameDescList detectGameFilebased(const StringMap &allFiles, const Common::ADParams &params) {
+static ADGameDescList detectGameFilebased(const FileMap &allFiles, const Common::ADParams &params) {
const ADFileBasedFallback *ptr;
const char* const* filenames;
diff --git a/common/archive.cpp b/common/archive.cpp
index 7e17fdca32..7f2b67eed0 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 {
@@ -53,7 +54,7 @@ int Archive::matchPattern(StringList &list, const String &pattern) {
}
-FSDirectory::FSDirectory(const FilesystemNode &node, int depth)
+FSDirectory::FSDirectory(const FSNode &node, int depth)
: _node(node), _cached(false), _depth(depth) {
}
@@ -64,11 +65,11 @@ FSDirectory::FSDirectory(const String &name, int depth)
FSDirectory::~FSDirectory() {
}
-FilesystemNode FSDirectory::getFSNode() const {
+FSNode FSDirectory::getFSNode() const {
return _node;
}
-FilesystemNode FSDirectory::lookupCache(NodeCache &cache, const String &name) {
+FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) {
// make caching as lazy as possible
if (!name.empty()) {
if (!_cached) {
@@ -80,7 +81,7 @@ FilesystemNode FSDirectory::lookupCache(NodeCache &cache, const String &name) {
return cache[name];
}
- return FilesystemNode();
+ return FSNode();
}
bool FSDirectory::hasFile(const String &name) {
@@ -88,7 +89,7 @@ bool FSDirectory::hasFile(const String &name) {
return false;
}
- FilesystemNode node = lookupCache(_fileCache, name);
+ FSNode node = lookupCache(_fileCache, name);
return node.exists();
}
@@ -97,13 +98,13 @@ SeekableReadStream *FSDirectory::openFile(const String &name) {
return 0;
}
- FilesystemNode node = lookupCache(_fileCache, name);
+ FSNode node = lookupCache(_fileCache, name);
if (!node.exists()) {
- warning("FSDirectory::openFile: FilesystemNode does not exist");
+ warning("FSDirectory::openFile: FSNode does not exist");
return 0;
} else if (node.isDirectory()) {
- warning("FSDirectory::openFile: FilesystemNode is a directory");
+ warning("FSDirectory::openFile: FSNode is a directory");
return 0;
}
@@ -120,17 +121,17 @@ FSDirectory *FSDirectory::getSubDirectory(const String &name) {
return 0;
}
- FilesystemNode node = lookupCache(_subDirCache, name);
+ FSNode node = lookupCache(_subDirCache, name);
return new FSDirectory(node);
}
-void FSDirectory::cacheDirectoryRecursive(FilesystemNode node, int depth, const String& prefix) {
+void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) {
if (depth <= 0) {
return;
}
FSList list;
- node.getChildren(list, FilesystemNode::kListAll, false);
+ node.getChildren(list, FSNode::kListAll, false);
FSList::iterator it = list.begin();
for ( ; it != list.end(); it++) {
@@ -231,9 +232,9 @@ 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 };
+ Node node(priority, name, archive);
insert(node);
} else {
warning("SearchSet::add: archive '%s' already present", name.c_str());
@@ -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,17 +329,33 @@ SeekableReadStream *SearchSet::openFile(const String &name) {
DECLARE_SINGLETON(SearchManager);
-void SearchManager::addArchive(const String &name, ArchivePtr archive) {
- add(name, archive);
+SearchManager::SearchManager() {
+ clear(); // Force a reset
}
-void SearchManager::addDirectory(const String &name, const String &directory) {
- addDirectoryRecursive(name, 1);
+void SearchManager::addArchive(const String &name, ArchivePtr archive, int priority) {
+ add(name, archive, priority);
}
-void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth) {
- add(name, SharedPtr<FSDirectory>(new FSDirectory(directory, depth)));
+void SearchManager::addDirectory(const String &name, const String &directory, int priority) {
+ addDirectoryRecursive(name, directory, 1, priority);
}
+void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth, int priority) {
+ add(name, ArchivePtr(new FSDirectory(directory, depth)), priority);
+}
+
+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);
+
+ // Add the current dir as a very last resort.
+ // See also bug #2137680.
+ add(".", ArchivePtr(new FSDirectory(".")), -2);
+}
} // namespace Common
diff --git a/common/archive.h b/common/archive.h
index 89ea6a5ce2..9103586d7d 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -93,21 +93,21 @@ typedef SharedPtr<Archive> ArchivePtr;
* Searching is case-insensitive, as the main intended goal is supporting
* retrieval of game data. First case-insensitive match is returned when
* searching, thus making FSDirectory heavily dependant on the underlying
- * FilesystemNode implementation.
+ * FSNode implementation.
*/
class FSDirectory : public Archive {
- FilesystemNode _node;
+ FSNode _node;
// Caches are case insensitive, clashes are dealt with when creating
// Key is stored in lowercase.
- typedef HashMap<String, FilesystemNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache;
+ typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache;
NodeCache _fileCache, _subDirCache;
// look for a match
- FilesystemNode lookupCache(NodeCache &cache, const String &name);
+ FSNode lookupCache(NodeCache &cache, const String &name);
// cache management
- void cacheDirectoryRecursive(FilesystemNode node, int depth, const String& prefix);
+ void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix);
bool _cached;
int _depth;
@@ -122,14 +122,14 @@ public:
* Create a FSDirectory representing a tree with the specified depth. Will result in an
* unbound FSDirectory if node does not exist or is not a directory.
*/
- FSDirectory(const FilesystemNode &node, int depth = 1);
+ FSDirectory(const FSNode &node, int depth = 1);
virtual ~FSDirectory();
/**
* This return the underlying FSNode of the FSDirectory.
*/
- FilesystemNode getFSNode() const;
+ FSNode getFSNode() const;
/**
* Create a new FSDirectory pointing to a sub directory of the instance.
@@ -153,9 +153,12 @@ public:
*/
class SearchSet : public Archive {
struct Node {
- uint _priority;
+ int _priority;
String _name;
ArchivePtr _arc;
+ Node(int priority, const String &name, ArchivePtr arc)
+ : _priority(priority), _name(name), _arc(arc) {
+ }
};
typedef List<Node> ArchiveList;
ArchiveList _list;
@@ -169,7 +172,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 +187,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,22 +208,28 @@ 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.
*/
- void addArchive(const String &name, ArchivePtr archive);
+ void addArchive(const String &name, ArchivePtr archive, int priority = 0);
/**
* Create and add a FSDirectory by name
*/
- void addDirectory(const String &name, const String &directory);
+ void addDirectory(const String &name, const String &directory, int priority = 0);
/**
* Create and add a FSDirectory and its subdirectories by name
*/
- void addDirectoryRecursive(const String &name, const String &directory, int depth = 4);
+ void addDirectoryRecursive(const String &name, const String &directory, int depth = 4, int priority = 0);
+ /**
+ * TODO
+ */
+ virtual void clear();
};
/** Shortcut for accessing the search manager. */
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index b741757cc5..0d01c39c4f 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -77,8 +77,9 @@ void ConfigManager::loadDefaultConfigFile() {
void ConfigManager::loadConfigFile(const String &filename) {
_filename = filename;
+ FSNode node(filename);
File cfg_file;
- if (!cfg_file.open(filename)) {
+ if (!cfg_file.open(node)) {
printf("Creating configuration file: %s\n", filename.c_str());
} else {
printf("Using configuration file: %s\n", _filename.c_str());
diff --git a/common/file.cpp b/common/file.cpp
index cf396a32cd..ed432ce565 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -31,39 +31,30 @@
namespace Common {
-static Common::SearchSet *s_searchSet = 0;
-
-
void File::addDefaultDirectory(const String &directory) {
- FilesystemNode dir(directory);
+ FSNode dir(directory);
addDefaultDirectoryRecursive(dir, 1);
}
void File::addDefaultDirectoryRecursive(const String &directory, int level) {
- FilesystemNode dir(directory);
+ FSNode dir(directory);
addDefaultDirectoryRecursive(dir, level);
}
-void File::addDefaultDirectory(const FilesystemNode &directory) {
+void File::addDefaultDirectory(const FSNode &directory) {
addDefaultDirectoryRecursive(directory, 1);
}
-void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level) {
+void File::addDefaultDirectoryRecursive(const FSNode &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()
@@ -74,78 +65,66 @@ File::~File() {
close();
}
-
bool File::open(const String &filename) {
+ return open(filename, SearchMan);
+}
+
+bool File::open(const String &filename, Archive &archive) {
assert(!filename.empty());
assert(!_handle);
- _name.clear();
clearIOFailed();
- if (s_searchSet && s_searchSet->hasFile(filename)) {
+ SeekableReadStream *stream = 0;
+ if (archive.hasFile(filename)) {
debug(3, "Opening hashed: %s", filename.c_str());
- _handle = s_searchSet->openFile(filename);
- } else if (s_searchSet && s_searchSet->hasFile(filename + ".")) {
+ stream = archive.openFile(filename);
+ } else if (archive.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);
- } else {
- // Last resort: try the current directory
- FilesystemNode file(filename);
- if (file.exists() && !file.isDirectory())
- _handle = file.openForReading();
+ stream = archive.openFile(filename + ".");
}
- if (_handle == NULL)
- debug(2, "File %s not opened", filename.c_str());
- else
- _name = filename;
-
- return _handle != NULL;
+ return open(stream, filename);
}
-bool File::open(const FilesystemNode &node) {
+bool File::open(const FSNode &node) {
+ assert(!_handle);
if (!node.exists()) {
- warning("File::open: FilesystemNode does not exist");
+ warning("File::open: '%s' does not exist", node.getPath().c_str());
return false;
} else if (node.isDirectory()) {
- warning("File::open: FilesystemNode is a directory");
+ warning("File::open: '%s' is a directory", node.getPath().c_str());
return false;
}
- String filename(node.getName());
-
- if (_handle) {
- error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str());
- }
+ SeekableReadStream *stream = node.openForReading();
+ return open(stream, node.getPath());
+}
+bool File::open(SeekableReadStream *stream, const Common::String &name) {
+ assert(!_handle);
clearIOFailed();
- _name.clear();
-
- _handle = node.openForReading();
-
- if (_handle == NULL)
- debug(2, "File %s not found", filename.c_str());
- else
- _name = filename;
+ if (stream) {
+ _handle = stream;
+ _name = name;
+ } else {
+ debug(2, "File::open: opening '%s' failed", name.c_str());
+ }
return _handle != NULL;
}
+
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;
- } else {
- // Last resort: try the current directory
- FilesystemNode file(filename);
- if (file.exists() && !file.isDirectory())
- return true;
}
return false;
@@ -217,15 +196,15 @@ bool DumpFile::open(const String &filename) {
assert(!filename.empty());
assert(!_handle);
- FilesystemNode node(filename);
+ FSNode node(filename);
return open(node);
}
-bool DumpFile::open(const FilesystemNode &node) {
+bool DumpFile::open(const FSNode &node) {
assert(!_handle);
if (node.isDirectory()) {
- warning("DumpFile::open: FilesystemNode is a directory");
+ warning("DumpFile::open: FSNode is a directory");
return false;
}
diff --git a/common/file.h b/common/file.h
index a2739f795f..0634aecdd3 100644
--- a/common/file.h
+++ b/common/file.h
@@ -27,13 +27,14 @@
#define COMMON_FILE_H
#include "common/scummsys.h"
+#include "common/archive.h"
#include "common/noncopyable.h"
#include "common/str.h"
#include "common/stream.h"
namespace Common {
-class FilesystemNode;
+class FSNode;
/**
* TODO: vital to document this core class properly!!! For both users and implementors
@@ -43,7 +44,7 @@ protected:
/** File handle to the actual file; 0 if no file is open. */
SeekableReadStream *_handle;
- /** The name of this file, for debugging. */
+ /** The name of this file, kept for debugging purposes. */
String _name;
public:
@@ -51,11 +52,12 @@ public:
static void addDefaultDirectory(const String &directory);
static void addDefaultDirectoryRecursive(const String &directory, int level = 4);
- static void addDefaultDirectory(const FilesystemNode &directory);
- static void addDefaultDirectoryRecursive(const FilesystemNode &directory, int level = 4);
+ static void addDefaultDirectory(const FSNode &directory);
+ static void addDefaultDirectoryRecursive(const FSNode &directory, int level = 4);
static void resetDefaultDirectories();
+
File();
virtual ~File();
@@ -64,14 +66,56 @@ public:
* (those were/are added by addDefaultDirectory and/or
* addDefaultDirectoryRecursive).
*
- * @param filename: the file to check for
- * @return: true if the file exists, else false
+ * @param filename the file to check for
+ * @return true if the file exists, false otherwise
*/
static bool exists(const String &filename);
+ /**
+ * Try to open the file with the given filename, by searching SearchMan.
+ * @note Must not be called if this file already is open (i.e. if isOpen returns true).
+ *
+ * @param filename the name of the file to open
+ * @return true if file was opened successfully, false otherwise
+ */
virtual bool open(const String &filename);
- virtual bool open(const FilesystemNode &node);
+ /**
+ * Try to open the file with the given filename from within the given archive.
+ * @note Must not be called if this file already is open (i.e. if isOpen returns true).
+ *
+ * @param filename the name of the file to open
+ * @param archive the archive in which to search for the file
+ * @return true if file was opened successfully, false otherwise
+ */
+ virtual bool open(const String &filename, Archive &archive);
+
+ /**
+ * Try to open the file corresponding to the give node. Will check whether the
+ * node actually refers to an existing file (and not a directory), and handle
+ * those cases gracefully.
+ * @note Must not be called if this file already is open (i.e. if isOpen returns true).
+ *
+ * @param filename the name of the file to open
+ * @param archive the archive in which to search for the file
+ * @return true if file was opened successfully, false otherwise
+ */
+ virtual bool open(const FSNode &node);
+
+ /**
+ * Try to 'open' the given stream. That is, we just wrap around it, and if stream
+ * is a NULL pointer, we gracefully treat this as if opening failed.
+ * @note Must not be called if this file already is open (i.e. if isOpen returns true).
+ *
+ * @param stream a pointer to a SeekableReadStream, or 0
+ * @param name a string describing the 'file' corresponding to stream
+ * @return true if stream was 0, false otherwise
+ */
+ virtual bool open(SeekableReadStream *stream, const Common::String &name);
+
+ /**
+ * Close the file, if open.
+ */
virtual void close();
/**
@@ -82,11 +126,11 @@ public:
bool isOpen() const;
/**
- * Returns the filename of the opened file.
+ * Returns the filename of the opened file for debugging purposes.
*
* @return: the filename
*/
- const char *name() const { return _name.c_str(); }
+ const char *getName() const { return _name.c_str(); }
bool ioFailed() const;
void clearIOFailed();
@@ -117,7 +161,7 @@ public:
virtual ~DumpFile();
virtual bool open(const String &filename);
- virtual bool open(const FilesystemNode &node);
+ virtual bool open(const FSNode &node);
virtual void close();
diff --git a/common/fs.cpp b/common/fs.cpp
index 4d31ac09fa..c1ef26e42d 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -29,48 +29,48 @@
namespace Common {
-FilesystemNode::FilesystemNode() {
+FSNode::FSNode() {
}
-FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode)
+FSNode::FSNode(AbstractFSNode *realNode)
: _realNode(realNode) {
}
-FilesystemNode::FilesystemNode(const Common::String &p) {
+FSNode::FSNode(const Common::String &p) {
FilesystemFactory *factory = g_system->getFilesystemFactory();
- AbstractFilesystemNode *tmp = 0;
+ AbstractFSNode *tmp = 0;
if (p.empty() || p == ".")
tmp = factory->makeCurrentDirectoryFileNode();
else
tmp = factory->makeFileNodePath(p);
- _realNode = Common::SharedPtr<AbstractFilesystemNode>(tmp);
+ _realNode = Common::SharedPtr<AbstractFSNode>(tmp);
}
-bool FilesystemNode::operator<(const FilesystemNode& node) const {
+bool FSNode::operator<(const FSNode& node) const {
if (isDirectory() != node.isDirectory())
return isDirectory();
return getDisplayName().compareToIgnoreCase(node.getDisplayName()) < 0;
}
-bool FilesystemNode::exists() const {
+bool FSNode::exists() const {
if (_realNode == 0)
return false;
return _realNode->exists();
}
-FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
+FSNode FSNode::getChild(const Common::String &n) const {
// If this node is invalid or not a directory, return an invalid node
if (_realNode == 0 || !_realNode->isDirectory())
- return FilesystemNode();
+ return FSNode();
- AbstractFilesystemNode *node = _realNode->getChild(n);
- return FilesystemNode(node);
+ AbstractFSNode *node = _realNode->getChild(n);
+ return FSNode(node);
}
-bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
+bool FSNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
if (!_realNode || !_realNode->isDirectory())
return false;
@@ -81,61 +81,61 @@ bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) con
fslist.clear();
for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) {
- fslist.push_back(FilesystemNode(*i));
+ fslist.push_back(FSNode(*i));
}
return true;
}
-Common::String FilesystemNode::getDisplayName() const {
+Common::String FSNode::getDisplayName() const {
assert(_realNode);
return _realNode->getDisplayName();
}
-Common::String FilesystemNode::getName() const {
+Common::String FSNode::getName() const {
assert(_realNode);
return _realNode->getName();
}
-FilesystemNode FilesystemNode::getParent() const {
+FSNode FSNode::getParent() const {
if (_realNode == 0)
return *this;
- AbstractFilesystemNode *node = _realNode->getParent();
+ AbstractFSNode *node = _realNode->getParent();
if (node == 0) {
return *this;
} else {
- return FilesystemNode(node);
+ return FSNode(node);
}
}
-Common::String FilesystemNode::getPath() const {
+Common::String FSNode::getPath() const {
assert(_realNode);
return _realNode->getPath();
}
-bool FilesystemNode::isDirectory() const {
+bool FSNode::isDirectory() const {
if (_realNode == 0)
return false;
return _realNode->isDirectory();
}
-bool FilesystemNode::isReadable() const {
+bool FSNode::isReadable() const {
if (_realNode == 0)
return false;
return _realNode->isReadable();
}
-bool FilesystemNode::isWritable() const {
+bool FSNode::isWritable() const {
if (_realNode == 0)
return false;
return _realNode->isWritable();
}
-bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool hidden, bool exhaustive, int depth) const {
+bool FSNode::lookupFile(FSList &results, const Common::String &p, bool hidden, bool exhaustive, int depth) const {
if (!isDirectory())
return false;
@@ -146,7 +146,7 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h
pattern.toUppercase();
// First match all files on this level
- getChildren(children, FilesystemNode::kListAll, hidden);
+ getChildren(children, FSNode::kListAll, hidden);
for (FSList::iterator entry = children.begin(); entry != children.end(); ++entry) {
if (entry->isDirectory()) {
if (depth != 0)
@@ -173,27 +173,27 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h
return !results.empty();
}
-Common::SeekableReadStream *FilesystemNode::openForReading() const {
+Common::SeekableReadStream *FSNode::openForReading() const {
if (_realNode == 0)
return 0;
if (!_realNode->exists()) {
- warning("FilesystemNode::openForReading: FilesystemNode does not exist");
+ warning("FSNode::openForReading: FSNode does not exist");
return false;
} else if (_realNode->isDirectory()) {
- warning("FilesystemNode::openForReading: FilesystemNode is a directory");
+ warning("FSNode::openForReading: FSNode is a directory");
return false;
}
return _realNode->openForReading();
}
-Common::WriteStream *FilesystemNode::openForWriting() const {
+Common::WriteStream *FSNode::openForWriting() const {
if (_realNode == 0)
return 0;
if (_realNode->isDirectory()) {
- warning("FilesystemNode::openForWriting: FilesystemNode is a directory");
+ warning("FSNode::openForWriting: FSNode is a directory");
return 0;
}
diff --git a/common/fs.h b/common/fs.h
index c5f7ca6b4c..e2db955c87 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -29,11 +29,11 @@
#include "common/ptr.h"
#include "common/str.h"
-class AbstractFilesystemNode;
+class AbstractFSNode;
namespace Common {
-class FilesystemNode;
+class FSNode;
class SeekableReadStream;
class WriteStream;
@@ -42,21 +42,22 @@ class WriteStream;
* This is subclass instead of just a typedef so that we can use forward
* declarations of it in other places.
*/
-class FSList : public Common::Array<FilesystemNode> {};
+class FSList : public Common::Array<FSNode> {};
/**
- * FilesystemNode provides an abstraction for file paths, allowing for portable
- * file system browsing. To this ends, multiple or single roots have to be supported
- * (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
+ * FSNode, short for "File System Node", provides an abstraction for file
+ * paths, allowing for portable file system browsing. This means for example,
+ * that multiple or single roots have to be supported (compare Unix with a
+ * single root, Windows with multiple roots C:, D:, ...).
*
* To this end, we abstract away from paths; implementations can be based on
* paths (and it's left to them whether / or \ or : is the path separator :-);
* but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
*/
-class FilesystemNode {
+class FSNode {
private:
- Common::SharedPtr<AbstractFilesystemNode> _realNode;
- FilesystemNode(AbstractFilesystemNode *realNode);
+ Common::SharedPtr<AbstractFSNode> _realNode;
+ FSNode(AbstractFSNode *realNode);
public:
/**
@@ -69,14 +70,14 @@ public:
};
/**
- * Create a new pathless FilesystemNode. Since there's no path associated
+ * Create a new pathless FSNode. Since there's no path associated
* with this node, path-related operations (i.e. exists(), isDirectory(),
* getPath()) will always return false or raise an assertion.
*/
- FilesystemNode();
+ FSNode();
/**
- * Create a new FilesystemNode referring to the specified path. This is
+ * Create a new FSNode referring to the specified path. This is
* the counterpart to the path() method.
*
* If path is empty or equals ".", then a node representing the "current
@@ -84,15 +85,15 @@ public:
* operating system doesn't support the concept), some other directory is
* used (usually the root directory).
*/
- explicit FilesystemNode(const Common::String &path);
+ explicit FSNode(const Common::String &path);
- virtual ~FilesystemNode() {}
+ virtual ~FSNode() {}
/**
* Compare the name of this node to the name of another. Directories
* go before normal files.
*/
- bool operator<(const FilesystemNode& node) const;
+ bool operator<(const FSNode& node) const;
/**
* Indicates whether the object referred by this node exists in the filesystem or not.
@@ -118,7 +119,7 @@ public:
* @param name the name of a child of this directory
* @return the node referring to the child with the given name
*/
- FilesystemNode getChild(const Common::String &name) const;
+ FSNode getChild(const Common::String &name) const;
/**
* Return a list of all child nodes of this directory node. If called on a node
@@ -165,7 +166,7 @@ public:
* Get the parent node of this node. If this node has no parent node,
* then it returns a duplicate of this node.
*/
- FilesystemNode getParent() const;
+ FSNode getParent() const;
/**
* Indicates whether the node refers to a directory or not.
diff --git a/common/md5.cpp b/common/md5.cpp
index 4eeb3d9a39..107990481f 100644
--- a/common/md5.cpp
+++ b/common/md5.cpp
@@ -246,15 +246,15 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) {
PUT_UINT32(ctx->state[3], digest, 12);
}
-bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) {
+bool md5_file(const FSNode &file, uint8 digest[16], uint32 length) {
if (!file.exists()) {
- warning("md5_file: using an inexistent FilesystemNode");
+ warning("md5_file: using an inexistent FSNode");
return false;
} else if (!file.isReadable()) {
- warning("md5_file: using an unreadable FilesystemNode");
+ warning("md5_file: using an unreadable FSNode");
return false;
} else if (file.isDirectory()) {
- warning("md5_file: using a directory FilesystemNode");
+ warning("md5_file: using a directory FSNode");
return false;
}
@@ -316,7 +316,7 @@ bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length) {
return true;
}
-bool md5_file_string(const FilesystemNode &file, char *md5str, uint32 length) {
+bool md5_file_string(const FSNode &file, char *md5str, uint32 length) {
uint8 digest[16];
if (!md5_file(file, digest, length))
return false;
diff --git a/common/md5.h b/common/md5.h
index a8642b1322..ffed7d7524 100644
--- a/common/md5.h
+++ b/common/md5.h
@@ -29,11 +29,11 @@
namespace Common {
-class FilesystemNode;
+class FSNode;
class ReadStream;
bool md5_file(const char *name, uint8 digest[16], uint32 length = 0);
-bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length = 0);
+bool md5_file(const FSNode &file, uint8 digest[16], uint32 length = 0);
bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0);
// The following two methods work similar to the above two, but
@@ -41,7 +41,7 @@ bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0);
// a human readable lowercase hexstring representing the digest.
// The md5str parameter must point to a buffer of 32+1 chars.
bool md5_file_string(const char *name, char *md5str, uint32 length = 0);
-bool md5_file_string(const FilesystemNode &file, char *md5str, uint32 length = 0);
+bool md5_file_string(const FSNode &file, char *md5str, uint32 length = 0);
bool md5_file_string(ReadStream &stream, char *md5str, uint32 length = 0);
diff --git a/common/str.cpp b/common/str.cpp
index 6c48738533..303ed7bfac 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -339,7 +339,8 @@ bool String::matchString(const String &pat) const {
}
void String::deleteLastChar() {
- deleteChar(_size - 1);
+ if (_size > 0)
+ deleteChar(_size - 1);
}
void String::deleteChar(uint32 p) {
diff --git a/common/str.h b/common/str.h
index 772718a087..c3e773c3e4 100644
--- a/common/str.h
+++ b/common/str.h
@@ -112,7 +112,7 @@ public:
String(const String &str);
/** Construct a string consisting of the given character. */
- String(char c);
+ explicit String(char c);
~String();
diff --git a/common/system.cpp b/common/system.cpp
index d9bc027e91..0e29dded38 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -163,7 +163,7 @@ static Common::String getDefaultConfigFileName() {
}
Common::SeekableReadStream *OSystem::openConfigFileForReading() {
- Common::FilesystemNode file(getDefaultConfigFileName());
+ Common::FSNode file(getDefaultConfigFileName());
return file.openForReading();
}
@@ -171,7 +171,7 @@ Common::WriteStream *OSystem::openConfigFileForWriting() {
#ifdef __DC__
return 0;
#else
- Common::FilesystemNode file(getDefaultConfigFileName());
+ Common::FSNode file(getDefaultConfigFileName());
return file.openForWriting();
#endif
}
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
diff --git a/common/unarj.cpp b/common/unarj.cpp
index 244a296efb..00f51ac252 100644
--- a/common/unarj.cpp
+++ b/common/unarj.cpp
@@ -324,15 +324,15 @@ uint32 ArjFile::read(void *dataPtr, uint32 dataSize) {
return _uncompressed->read(dataPtr, dataSize);
}
-bool ArjFile::eos() {
+bool ArjFile::eos() const {
return _uncompressed->eos();
}
-int32 ArjFile::pos() {
+int32 ArjFile::pos() const {
return _uncompressed->pos();
}
-int32 ArjFile::size() {
+int32 ArjFile::size() const {
return _uncompressed->size();
}
diff --git a/common/unarj.h b/common/unarj.h
index 52e0d13948..d16d748ad3 100644
--- a/common/unarj.h
+++ b/common/unarj.h
@@ -85,7 +85,7 @@ struct ArjHeader {
typedef HashMap<String, int, IgnoreCase_Hash, IgnoreCase_EqualTo> ArjFilesMap;
-class ArjFile : public File {
+class ArjFile : public SeekableReadStream, public NonCopyable {
public:
ArjFile();
~ArjFile();
@@ -98,9 +98,9 @@ public:
void close();
uint32 read(void *dataPtr, uint32 dataSize);
- bool eos();
- int32 pos();
- int32 size();
+ bool eos() const;
+ int32 pos() const;
+ int32 size() const;
bool seek(int32 offset, int whence = SEEK_SET);
bool isOpen() { return _isOpen; }
diff --git a/common/unzip.cpp b/common/unzip.cpp
index 054200e7a2..894631b262 100644
--- a/common/unzip.cpp
+++ b/common/unzip.cpp
@@ -1363,7 +1363,7 @@ class ZipArchiveMember : public ArchiveMember {
unzFile _zipFile;
public:
- ZipArchiveMember(FilesystemNode &node) : _node(node) {
+ ZipArchiveMember(FSNode &node) : _node(node) {
}
String getName() const {
@@ -1393,7 +1393,22 @@ bool ZipArchive::hasFile(const Common::String &name) {
}
int ZipArchive::getAllNames(Common::StringList &list) {
- return 0;
+ if (!_zipFile)
+ return 0;
+
+ if (unzGoToFirstFile(_zipFile) != UNZ_OK)
+ return 0;
+
+ char fileNameBuffer[UNZ_MAXFILENAMEINZIP + 1];
+ int fileCount = 0;
+
+ do {
+ unzGetCurrentFileInfo(_zipFile, 0, fileNameBuffer, UNZ_MAXFILENAMEINZIP + 1, 0, 0, 0, 0);
+ list.push_back(Common::String(fileNameBuffer));
+ fileCount++;
+ } while (unzGoToNextFile(_zipFile) == UNZ_OK);
+
+ return fileCount;
}
/*
diff --git a/common/unzip.h b/common/unzip.h
index 93afd0b05b..e4eb754eee 100644
--- a/common/unzip.h
+++ b/common/unzip.h
@@ -44,7 +44,7 @@ public:
bool isOpen() const;
virtual bool hasFile(const String &name);
- virtual int getAllNames(StringList &list); // FIXME: This one is not (yet?) implemented
+ virtual int getAllNames(StringList &list);
virtual Common::SeekableReadStream *openFile(const Common::String &name);
};
diff --git a/common/xmlparser.h b/common/xmlparser.h
index dcbfc60c2f..3b085eb544 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -187,7 +187,7 @@ public:
return true;
}
- bool loadFile(const FilesystemNode &node) {
+ bool loadFile(const FSNode &node) {
Common::File *f = new Common::File;
if (!f->open(node)) {