aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/fs.cpp23
-rw-r--r--common/fs.h14
2 files changed, 14 insertions, 23 deletions
diff --git a/common/fs.cpp b/common/fs.cpp
index 12f0ea98ef..b121d273c8 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -49,17 +49,17 @@ FSNode::FSNode(const Common::String &p) {
}
bool FSNode::operator<(const FSNode& node) const {
+ // Directories come before files, i.e., are "lower".
if (isDirectory() != node.isDirectory())
return isDirectory();
+ // If both nodes are of the same type (two files or two dirs),
+ // then sort by name, ignoring case.
return getDisplayName().compareToIgnoreCase(node.getDisplayName()) < 0;
}
bool FSNode::exists() const {
- if (_realNode == 0)
- return false;
-
- return _realNode->exists();
+ return _realNode && _realNode->exists();
}
FSNode FSNode::getChild(const Common::String &n) const {
@@ -116,24 +116,15 @@ Common::String FSNode::getPath() const {
}
bool FSNode::isDirectory() const {
- if (_realNode == 0)
- return false;
-
- return _realNode->isDirectory();
+ return _realNode && _realNode->isDirectory();
}
bool FSNode::isReadable() const {
- if (_realNode == 0)
- return false;
-
- return _realNode->isReadable();
+ return _realNode && _realNode->isReadable();
}
bool FSNode::isWritable() const {
- if (_realNode == 0)
- return false;
-
- return _realNode->isWritable();
+ return _realNode && _realNode->isWritable();
}
Common::SeekableReadStream *FSNode::createReadStream() const {
diff --git a/common/fs.h b/common/fs.h
index d0e3c23558..6b20a05013 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -101,7 +101,7 @@ public:
*
* @return bool true if the node exists, false otherwise.
*/
- virtual bool exists() const;
+ bool exists() const;
/**
* Create a new node referring to a child node of the current node, which
@@ -128,7 +128,7 @@ public:
*
* @return true if successful, false otherwise (e.g. when the directory does not exist).
*/
- virtual bool getChildren(FSList &fslist, ListMode mode = kListDirectoriesOnly, bool hidden = false) const;
+ bool getChildren(FSList &fslist, ListMode mode = kListDirectoriesOnly, bool hidden = false) const;
/**
* Return a human readable string for this node, usable for display (e.g.
@@ -161,7 +161,7 @@ public:
*
* @return the 'path' represented by this filesystem node
*/
- virtual String getPath() const;
+ String getPath() const;
/**
* Get the parent node of this node. If this node has no parent node,
@@ -178,7 +178,7 @@ public:
* Or even replace isDirectory by a getType() method that can return values like
* kDirNodeType, kFileNodeType, kInvalidNodeType.
*/
- virtual bool isDirectory() const;
+ bool isDirectory() const;
/**
* Indicates whether the object referred by this node can be read from or not.
@@ -191,7 +191,7 @@ public:
*
* @return true if the object can be read, false otherwise.
*/
- virtual bool isReadable() const;
+ bool isReadable() const;
/**
* Indicates whether the object referred by this node can be written to or not.
@@ -204,7 +204,7 @@ public:
*
* @return true if the object can be written to, false otherwise.
*/
- virtual bool isWritable() const;
+ bool isWritable() const;
/**
* Creates a SeekableReadStream instance corresponding to the file
@@ -222,7 +222,7 @@ public:
*
* @return pointer to the stream object, 0 in case of a failure
*/
- virtual WriteStream *createWriteStream() const;
+ WriteStream *createWriteStream() const;
};
/**