diff options
Diffstat (limited to 'common/fs.cpp')
| -rw-r--r-- | common/fs.cpp | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/common/fs.cpp b/common/fs.cpp index 3f585c6038..4d31ac09fa 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -23,12 +23,11 @@ */ #include "common/util.h" -#include "common/file.h" #include "common/system.h" #include "backends/fs/abstract-fs.h" #include "backends/fs/fs-factory.h" -//namespace Common { +namespace Common { FilesystemNode::FilesystemNode() { } @@ -52,7 +51,7 @@ bool FilesystemNode::operator<(const FilesystemNode& node) const { if (isDirectory() != node.isDirectory()) return isDirectory(); - return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0; + return getDisplayName().compareToIgnoreCase(node.getDisplayName()) < 0; } bool FilesystemNode::exists() const { @@ -63,10 +62,10 @@ bool FilesystemNode::exists() const { } FilesystemNode FilesystemNode::getChild(const Common::String &n) const { - if (_realNode == 0) - return *this; + // If this node is invalid or not a directory, return an invalid node + if (_realNode == 0 || !_realNode->isDirectory()) + return FilesystemNode(); - assert(_realNode->isDirectory()); AbstractFilesystemNode *node = _realNode->getChild(n); return FilesystemNode(node); } @@ -155,7 +154,7 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h } else { Common::String filename = entry->getName(); filename.toUppercase(); - if (Common::matchString(filename.c_str(), pattern.c_str())) { + if (filename.matchString(pattern)) { results.push_back(*entry); if (!exhaustive) @@ -174,40 +173,31 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h return !results.empty(); } -Common::SeekableReadStream *FilesystemNode::openForReading() { +Common::SeekableReadStream *FilesystemNode::openForReading() const { if (_realNode == 0) return 0; -#if 0 - return _realNode->openForReading(); -#else - // FIXME: Until we support openForReading in AbstractFilesystemNode, - // we just use Common::File. - Common::File *confFile = new Common::File(); - assert(confFile); - if (!confFile->open(*this)) { - delete confFile; - confFile = 0; + + if (!_realNode->exists()) { + warning("FilesystemNode::openForReading: FilesystemNode does not exist"); + return false; + } else if (_realNode->isDirectory()) { + warning("FilesystemNode::openForReading: FilesystemNode is a directory"); + return false; } - return confFile; -#endif + + return _realNode->openForReading(); } -Common::WriteStream *FilesystemNode::openForWriting() { +Common::WriteStream *FilesystemNode::openForWriting() const { if (_realNode == 0) return 0; -#if 0 - return _realNode->openForWriting(); -#else - // FIXME: Until we support openForWriting in AbstractFilesystemNode, - // we just use Common::DumpFile. - Common::DumpFile *confFile = new Common::DumpFile(); - assert(confFile); - if (!confFile->open(*this)) { - delete confFile; - confFile = 0; + + if (_realNode->isDirectory()) { + warning("FilesystemNode::openForWriting: FilesystemNode is a directory"); + return 0; } - return confFile; -#endif + + return _realNode->openForWriting(); } -//} // End of namespace Common +} // End of namespace Common |
