diff options
author | David Corrales | 2007-06-16 17:31:36 +0000 |
---|---|---|
committer | David Corrales | 2007-06-16 17:31:36 +0000 |
commit | f7ea7e666da6e484577d0341fb0331dff75c69f7 (patch) | |
tree | b7e0b6ce4287cba50ee72e2ab50ca31d942466b2 | |
parent | b405220ff2990b01b93c03a664ae9247b2fc422c (diff) | |
download | scummvm-rg350-f7ea7e666da6e484577d0341fb0331dff75c69f7.tar.gz scummvm-rg350-f7ea7e666da6e484577d0341fb0331dff75c69f7.tar.bz2 scummvm-rg350-f7ea7e666da6e484577d0341fb0331dff75c69f7.zip |
Removed the isValid operation from the FilesystemNode class in favor of the much richer combinations possible with the new operations (exists, isReadable and isWritable).
The work on the Common::File class is far from complete. Only the necessary was updated.
svn-id: r27473
-rw-r--r-- | backends/fs/abstract-fs.h | 5 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 1 | ||||
-rw-r--r-- | common/file.cpp | 14 | ||||
-rw-r--r-- | common/fs.cpp | 6 | ||||
-rw-r--r-- | common/fs.h | 5 | ||||
-rw-r--r-- | common/md5.cpp | 9 | ||||
-rw-r--r-- | gui/themebrowser.cpp | 2 |
7 files changed, 17 insertions, 25 deletions
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index bb7669739f..fed2b9b4c5 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -122,11 +122,6 @@ public: virtual bool isReadable() const = 0; /** - * Indicates whether this path is valid or not for usage. - */ - virtual bool isValid() const = 0; - - /** * Indicates whether this path can be written to or not. */ virtual bool isWritable() const = 0; diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 2e222f34f8..fb5c9dc5d7 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -68,7 +68,6 @@ public: virtual String getPath() const { return _path; } virtual bool isDirectory() const { return _isDirectory; } virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } - virtual bool isValid() const { return _isValid; } virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } virtual AbstractFilesystemNode *getChild(const String &n) const; diff --git a/common/file.cpp b/common/file.cpp index c04c579535..0df575ac82 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -364,13 +364,19 @@ bool File::open(const String &filename, AccessMode mode) { bool File::open(const FilesystemNode &node, AccessMode mode) { assert(mode == kFileReadMode || mode == kFileWriteMode); - if (!node.isValid()) { - warning("File::open: Trying to open an invalid FilesystemNode object"); + if (!node.exists()) { + warning("File::open: Trying to open a FilesystemNode which does not exist"); return false; } else if (node.isDirectory()) { warning("File::open: Trying to open a FilesystemNode which is a directory"); return false; - } + } /*else if (!node.isReadable() && mode == kFileReadMode) { + warning("File::open: Trying to open an unreadable FilesystemNode object for reading"); + return false; + } else if (!node.isWritable() && mode == kFileWriteMode) { + warning("File::open: Trying to open an unwritable FilesystemNode object for writing"); + return false; + }*/ String filename(node.getName()); @@ -409,7 +415,7 @@ bool File::exists(const String &filename) { // FIXME: can't use isValid() here since at the time of writing // FilesystemNode is to be unable to find for example files // added in extrapath - if (file.isDirectory()) + if (file.isDirectory() && !file.exists()) return false; // Next, try to locate the file by *opening* it in read mode. This has diff --git a/common/fs.cpp b/common/fs.cpp index fdc485a06f..fc091262d7 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -161,12 +161,6 @@ bool FilesystemNode::isReadable() const { return _realNode->isReadable(); } -bool FilesystemNode::isValid() const { - if (_realNode == 0) - return false; - return _realNode->isValid(); -} - bool FilesystemNode::isWritable() const { if (_realNode == 0) return false; diff --git a/common/fs.h b/common/fs.h index 6b0a587e1b..328bebb15b 100644 --- a/common/fs.h +++ b/common/fs.h @@ -194,11 +194,6 @@ public: virtual bool isReadable() const; /** - * Indicates whether this path is valid or not for usage. - */ - bool isValid() const; - - /** * Indicates whether this path can be written to or not. */ virtual bool isWritable() const; diff --git a/common/md5.cpp b/common/md5.cpp index 35fbe0b9ab..32acdc5b8c 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -246,11 +246,14 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) { } bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) { - if (!file.isValid()) { - warning("md5_file: using an invalid FilesystemNode"); + if(!file.exists()) { + warning("md5_file: using an inexistent FilesystemNode"); + return false; + } else if (!file.isReadable()) { + warning("md5_file: using an unreadable FilesystemNode"); return false; } else if (file.isDirectory()) { - warning("md5_file: using a diretory FilesystemNode"); + warning("md5_file: using a directory FilesystemNode"); return false; } diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index 4d8c439872..75fe5404c4 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -144,7 +144,7 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { FilesystemNode node(dir); - if (!node.isValid()) + if (!node.exists() || !node.isReadable()) return; FSList fslist; |