aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2006-07-22 14:14:16 +0000
committerMax Horn2006-07-22 14:14:16 +0000
commit6ed00cd055abcc98b8ad5d4e2ac6396852ec9c95 (patch)
treea3f1c83c0bc528f22576bd3f523af49f2a805460 /common
parent42cebc00dcb5c274c96f69bb2658906d1ce269ec (diff)
downloadscummvm-rg350-6ed00cd055abcc98b8ad5d4e2ac6396852ec9c95.tar.gz
scummvm-rg350-6ed00cd055abcc98b8ad5d4e2ac6396852ec9c95.tar.bz2
scummvm-rg350-6ed00cd055abcc98b8ad5d4e2ac6396852ec9c95.zip
Added FilesystemNode::name method
svn-id: r23553
Diffstat (limited to 'common')
-rw-r--r--common/fs.cpp17
-rw-r--r--common/fs.h31
2 files changed, 34 insertions, 14 deletions
diff --git a/common/fs.cpp b/common/fs.cpp
index 3836dfc212..56d7eab49b 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -89,12 +89,12 @@ FilesystemNode FilesystemNode::getParent() const {
}
}
-FilesystemNode FilesystemNode::getChild(const String &name) const {
+FilesystemNode FilesystemNode::getChild(const String &n) const {
if (_realNode == 0)
return *this;
assert(_realNode->isDirectory());
- AbstractFilesystemNode *node = _realNode->child(name);
+ AbstractFilesystemNode *node = _realNode->child(n);
return FilesystemNode(node);
}
@@ -115,15 +115,20 @@ bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
return true;
}
+bool FilesystemNode::isDirectory() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isDirectory();
+}
+
Common::String FilesystemNode::displayName() const {
assert(_realNode);
return _realNode->displayName();
}
-bool FilesystemNode::isDirectory() const {
- if (_realNode == 0)
- return false;
- return _realNode->isDirectory();
+Common::String FilesystemNode::name() const {
+ assert(_realNode);
+ return _realNode->name();
}
Common::String FilesystemNode::path() const {
diff --git a/common/fs.h b/common/fs.h
index a79d710024..d18793f015 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -135,6 +135,16 @@ public:
virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const;
/**
+ * Is this node pointing to a directory?
+ * @todo Currently we assume that a valid node that is not a directory
+ * automatically is a file (ignoring things like symlinks). That might
+ * actually be OK... but we could still add an isFile method. Or even replace
+ * isValid and isDirectory by a getType() method that can return values like
+ * kDirNodeType, kFileNodeType, kInvalidNodeType.
+ */
+ virtual bool isDirectory() const;
+
+ /**
* Return a human readable string for this node, usable for display (e.g.
* in the GUI code). Do *not* rely on it being usable for anything else,
* like constructing paths!
@@ -143,20 +153,25 @@ public:
virtual String displayName() const;
/**
- * Is this node pointing to a directory?
- * @todo Currently we assume that a valid node that is not a directory
- * automatically is a file (ignoring things like symlinks). That might
- * actually be OK... but we could still add an isFile method. Or even replace
- * isValid and isDirectory by a getType() method that can return values like
- * kDirNodeType, kFileNodeType, kInvalidNodeType.
+ * Return a string representation of the name of the file. This is can be
+ * used e.g. by detection code that relies on matching the name of a given
+ * file. But it is *not* suitable for use with fopen / File::open, nor
+ * should it be archived.
+ *
+ * @return the file name
*/
- virtual bool isDirectory() const;
+ virtual String name() const;
/**
* Return a string representation of the file which can be passed to fopen(),
* and is suitable for archiving (i.e. writing to the config file).
* This will usually be a 'path' (hence the name of the method), but can
- * be anything that fulfilly the above criterions.
+ * be anything that fulfills the above criterions.
+ *
+ * @note Do not assume that this string contains (back)slashes or any
+ * other kind of 'path separators'.
+ *
+ * @return the 'path' represented by this filesystem node
*/
virtual String path() const;