From 6ed00cd055abcc98b8ad5d4e2ac6396852ec9c95 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 22 Jul 2006 14:14:16 +0000 Subject: Added FilesystemNode::name method svn-id: r23553 --- common/fs.cpp | 17 +++++++++++------ common/fs.h | 31 +++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 14 deletions(-) (limited to 'common') 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 @@ -134,6 +134,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, @@ -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; -- cgit v1.2.3