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 --- backends/fs/abstract-fs.h | 6 +++++- backends/fs/amigaos4/amigaos4-fs.cpp | 33 +++++++++++++++++---------------- backends/fs/dc/dc-fs.cpp | 6 +++--- backends/fs/ds/ds-fs.cpp | 20 ++++++++++---------- backends/fs/ds/ds-fs.h | 1 + backends/fs/gp32/gp32-fs.cpp | 7 ++++--- backends/fs/morphos/abox-fs.cpp | 25 +++++++++++++------------ backends/fs/palmos/palmos-fs.cpp | 7 ++++--- backends/fs/posix/posix-fs.cpp | 7 ++++--- backends/fs/ps2/ps2-fs.cpp | 7 ++++--- backends/fs/psp/psp_fs.cpp | 7 ++++--- backends/fs/symbian/symbian-fs.cpp | 7 ++++--- backends/fs/windows/windows-fs.cpp | 7 ++++--- common/fs.cpp | 17 +++++++++++------ common/fs.h | 31 +++++++++++++++++++++++-------- 15 files changed, 111 insertions(+), 77 deletions(-) diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index 9b3e473103..7b5b7cbd1d 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -99,7 +99,11 @@ protected: public: virtual ~AbstractFilesystemNode() {} - virtual String displayName() const = 0; + virtual String name() const = 0; + + // By default, we use the actual file name as 'display name'. + virtual String displayName() const { return name(); } + virtual bool isDirectory() const = 0; /** diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index d87e7d6497..4cb5ac7481 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -64,6 +64,7 @@ class AmigaOSFilesystemNode : public AbstractFilesystemNode { virtual ~AmigaOSFilesystemNode(); virtual String displayName() const { return _sDisplayName; }; + virtual String name() const { return _sDisplayName; }; virtual bool isValid() const { return _bIsValid; }; virtual bool isDirectory() const { return _bIsDirectory; }; virtual String path() const { return _sPath; }; @@ -71,7 +72,7 @@ class AmigaOSFilesystemNode : public AbstractFilesystemNode { virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFSList listVolumes() const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() { @@ -159,11 +160,11 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam _pFileLock = 0; while (1) { - char *name = new char[bufSize]; - if (IDOS->NameFromLock(pLock, (STRPTR)name, bufSize) != DOSFALSE) { - _sPath = name; - _sDisplayName = pDisplayName ? pDisplayName : IDOS->FilePart((STRPTR)name); - delete [] name; + char *n = new char[bufSize]; + if (IDOS->NameFromLock(pLock, (STRPTR)n, bufSize) != DOSFALSE) { + _sPath = n; + _sDisplayName = pDisplayName ? pDisplayName : IDOS->FilePart((STRPTR)n); + delete [] n; break; } @@ -171,11 +172,11 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam _bIsValid = false; debug(6, "IoErr() != ERROR_LINE_TOO_LONG"); LEAVE(); - delete [] name; + delete [] n; return; } bufSize *= 2; - delete [] name; + delete [] n; } _bIsValid = false; @@ -327,12 +328,12 @@ AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const { return node; } -AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &n) const { assert(_bIsDirectory); String newPath(_sPath); if (_sPath.lastChar() != '/') newPath += '/'; - newPath += name; + newPath += n; return new AmigaOSFilesystemNode(newPath); } @@ -342,7 +343,7 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { AbstractFSList myList; const uint32 kLockFlags = LDF_READ | LDF_VOLUMES; - char name[MAXPATHLEN]; + char n[MAXPATHLEN]; struct DosList *dosList = IDOS->LockDosList(kLockFlags); if (!dosList) { @@ -360,13 +361,13 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { const char *volName = (const char *)BADDR(dosList->dol_Name)+1; const char *devName = (const char *)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name; - strcpy(name, volName); - strcat(name, ":"); + strcpy(n, volName); + strcat(n, ":"); - BPTR volumeLock = IDOS->Lock((STRPTR)name, SHARED_LOCK); + BPTR volumeLock = IDOS->Lock((STRPTR)n, SHARED_LOCK); if (volumeLock) { - sprintf(name, "%s (%s)", volName, devName); - AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, name); + sprintf(n, "%s (%s)", volName, devName); + AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, n); if (entry) { if (entry->isValid()) myList.push_back(entry); diff --git a/backends/fs/dc/dc-fs.cpp b/backends/fs/dc/dc-fs.cpp index 479beb538f..db097301ce 100644 --- a/backends/fs/dc/dc-fs.cpp +++ b/backends/fs/dc/dc-fs.cpp @@ -51,7 +51,7 @@ public: virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; @@ -163,14 +163,14 @@ AbstractFilesystemNode *RoninCDFilesystemNode::parent() const { return p; } -AbstractFilesystemNode *RoninCDFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *RoninCDFilesystemNode::child(const String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; - newPath += name; + newPath += n; RoninCDFilesystemNode *p = new RoninCDFilesystemNode(newPath, true); return p; diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index e2f0065e1d..e0e7be3fea 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -151,11 +151,11 @@ AbstractFilesystemNode* DSFileSystemNode::parent() const { } -AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& name) const { +AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& n) const { if (_path.lastChar() == '\\') { - return new DSFileSystemNode(_path + name); + return new DSFileSystemNode(_path + n); } else { - return new DSFileSystemNode(_path + "\\" + name); + return new DSFileSystemNode(_path + "\\" + n); } return NULL; @@ -193,14 +193,14 @@ bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const { if (_zipFile->restartFile()) { do { - char name[128]; - _zipFile->getFileName(name); + char n[128]; + _zipFile->getFileName(n); -// consolePrintf("file: %s\n", name); +// consolePrintf("file: %s\n", n); if ( (_zipFile->isDirectory() && ((mode == FilesystemNode::kListDirectoriesOnly) || (mode == FilesystemNode::kListAll)) ) || (!_zipFile->isDirectory() && ((mode == FilesystemNode::kListFilesOnly) || (mode == FilesystemNode::kListAll)) ) ) { - DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/" + String(name), _zipFile->isDirectory()); + DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/" + String(n), _zipFile->isDirectory()); dsfsn->_isDirectory = _zipFile->isDirectory(); dirList.push_back((dsfsn)); } @@ -311,11 +311,11 @@ AbstractFilesystemNode* GBAMPFileSystemNode::parent() const { } -AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& name) const { +AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& n) const { if (_path.lastChar() == '\\') { - return new DSFileSystemNode(_path + name); + return new DSFileSystemNode(_path + n); } else { - return new DSFileSystemNode(_path + "\\" + name); + return new DSFileSystemNode(_path + "\\" + n); } return NULL; diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h index b9957a5c69..2d16217f06 100644 --- a/backends/fs/ds/ds-fs.h +++ b/backends/fs/ds/ds-fs.h @@ -59,6 +59,7 @@ public: DSFileSystemNode(const String& path, bool isDir); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } diff --git a/backends/fs/gp32/gp32-fs.cpp b/backends/fs/gp32/gp32-fs.cpp index c9e615b05c..4d242d339f 100644 --- a/backends/fs/gp32/gp32-fs.cpp +++ b/backends/fs/gp32/gp32-fs.cpp @@ -39,13 +39,14 @@ public: GP32FilesystemNode(const String &path); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return true; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; #define MAX_PATH_SIZE 256 @@ -216,14 +217,14 @@ AbstractFilesystemNode *GP32FilesystemNode::parent() const { return p; } -AbstractFilesystemNode *GP32FilesystemNode::child(const String &name) const { +AbstractFilesystemNode *GP32FilesystemNode::child(const String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '\\') newPath += '\\'; - newPath += name; + newPath += n; GP32FilesystemNode *p = new GP32FilesystemNode(newPath); return p; diff --git a/backends/fs/morphos/abox-fs.cpp b/backends/fs/morphos/abox-fs.cpp index 33a54b514e..b2043fb1e6 100644 --- a/backends/fs/morphos/abox-fs.cpp +++ b/backends/fs/morphos/abox-fs.cpp @@ -46,6 +46,7 @@ class ABoxFilesystemNode : public AbstractFilesystemNode { ~ABoxFilesystemNode(); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } @@ -53,7 +54,7 @@ class ABoxFilesystemNode : public AbstractFilesystemNode { virtual bool listDir(AbstractFSList &list, ListMode mode) const; static AbstractFSList listRoot(); virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; @@ -82,11 +83,11 @@ ABoxFilesystemNode::ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name) _lock = NULL; for (;;) { - char name[bufsize]; - if (NameFromLock(lock, name, bufsize) != DOSFALSE) + char n[bufsize]; + if (NameFromLock(lock, n, bufsize) != DOSFALSE) { - _path = name; - _displayName = display_name ? display_name : FilePart(name); + _path = n; + _displayName = display_name ? display_name : FilePart(n); break; } if (IoErr() != ERROR_LINE_TOO_LONG) @@ -216,7 +217,7 @@ AbstractFilesystemNode *ABoxFilesystemNode::parent() const return node; } -AbstractFilesystemNode *ABoxFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *ABoxFilesystemNode::child(const String &n) const { TODO } @@ -225,7 +226,7 @@ AbstractFSList ABoxFilesystemNode::listRoot() AbstractFSList myList; DosList *dosList; CONST ULONG lockDosListFlags = LDF_READ | LDF_VOLUMES; - char name[256]; + char n[256]; dosList = LockDosList(lockDosListFlags); if (dosList == NULL) @@ -247,13 +248,13 @@ AbstractFSList ABoxFilesystemNode::listRoot() CONST_STRPTR device_name = (CONST_STRPTR)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name; BPTR volume_lock; - strcpy(name, volume_name); - strcat(name, ":"); - volume_lock = Lock(name, SHARED_LOCK); + strcpy(n, volume_name); + strcat(n, ":"); + volume_lock = Lock(n, SHARED_LOCK); if (volume_lock) { - sprintf(name, "%s (%s)", volume_name, device_name); - entry = new ABoxFilesystemNode(volume_lock, name); + sprintf(n, "%s (%s)", volume_name, device_name); + entry = new ABoxFilesystemNode(volume_lock, n); if (entry) { if (entry->isValid()) diff --git a/backends/fs/palmos/palmos-fs.cpp b/backends/fs/palmos/palmos-fs.cpp index 6163689e63..afdf26a4f5 100644 --- a/backends/fs/palmos/palmos-fs.cpp +++ b/backends/fs/palmos/palmos-fs.cpp @@ -44,13 +44,14 @@ public: PalmOSFilesystemNode(const String &p); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; private: static void addFile (AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data); @@ -179,13 +180,13 @@ AbstractFilesystemNode *PalmOSFilesystemNode::parent() const { } -AbstractFilesystemNode *PalmOSFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *PalmOSFilesystemNode::child(const String &n) const { assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; - newPath += name; + newPath += n; FileRef handle; UInt32 attr; diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index cd5d0209b8..6edcb8a84d 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -50,13 +50,14 @@ public: POSIXFilesystemNode(const String &path, bool verify); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; @@ -208,14 +209,14 @@ AbstractFilesystemNode *POSIXFilesystemNode::parent() const { return p; } -AbstractFilesystemNode *POSIXFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *POSIXFilesystemNode::child(const String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; - newPath += name; + newPath += n; POSIXFilesystemNode *p = new POSIXFilesystemNode(newPath, true); return p; diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp index 6c4e218c01..18d6df5bb3 100644 --- a/backends/fs/ps2/ps2-fs.cpp +++ b/backends/fs/ps2/ps2-fs.cpp @@ -42,6 +42,7 @@ public: Ps2FilesystemNode(const String &path); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return !_isRoot; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } @@ -50,7 +51,7 @@ public: virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); } - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() { @@ -188,7 +189,7 @@ AbstractFilesystemNode *Ps2FilesystemNode::parent() const { return new Ps2FilesystemNode(); } -AbstractFilesystemNode *Ps2FilesystemNode::child(const String &name) const { +AbstractFilesystemNode *Ps2FilesystemNode::child(const String &n) const { if (!_isDirectory) return NULL; @@ -200,7 +201,7 @@ AbstractFilesystemNode *Ps2FilesystemNode::child(const String &name) const { iox_dirent_t dirent; while (fio.dread(fd, &dirent) > 0) { - if (strcmp(name.c_str(), dirent.name) == 0) { + if (strcmp(n.c_str(), dirent.name) == 0) { Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode(); dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR); diff --git a/backends/fs/psp/psp_fs.cpp b/backends/fs/psp/psp_fs.cpp index d0bf07f85a..0ad98729a9 100644 --- a/backends/fs/psp/psp_fs.cpp +++ b/backends/fs/psp/psp_fs.cpp @@ -49,13 +49,14 @@ public: PSPFilesystemNode(const Common::String &p, bool verify); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() { @@ -157,14 +158,14 @@ AbstractFilesystemNode *PSPFilesystemNode::parent() const { return p; } -AbstractFilesystemNode *PSPFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *PSPFilesystemNode::child(const String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; - newPath += name; + newPath += n; PSPFilesystemNode *p = new PSPFilesystemNode(newPath, true); return p; diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index aa8e854125..b8a3e9312d 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -47,13 +47,14 @@ public: SymbianFilesystemNode(bool aIsRoot); SymbianFilesystemNode(const String &path); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; }; @@ -206,13 +207,13 @@ AbstractFilesystemNode *SymbianFilesystemNode::parent() const { return p; } -AbstractFilesystemNode *SymbianFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *SymbianFilesystemNode::child(const String &n) const { assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '\\') newPath += '\\'; - newPath += name; + newPath += n; TPtrC8 ptr((const unsigned char*) newPath.c_str(), newPath.size()); TFileName fname; diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 4c5cd44f49..aadfdc9d3e 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -45,13 +45,14 @@ public: WindowsFilesystemNode(const String &path); virtual String displayName() const { return _displayName; } + virtual String name() const { return _displayName; } virtual bool isValid() const { return _isValid; } virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; - virtual AbstractFilesystemNode *child(const String &name) const; + virtual AbstractFilesystemNode *child(const String &n) const; private: static char *toAscii(TCHAR *x); @@ -240,12 +241,12 @@ AbstractFilesystemNode *WindowsFilesystemNode::parent() const { return p; } -AbstractFilesystemNode *WindowsFilesystemNode::child(const String &name) const { +AbstractFilesystemNode *WindowsFilesystemNode::child(const String &n) const { assert(_isDirectory); String newPath(_path); if (_path.lastChar() != '\\') newPath += '\\'; - newPath += name; + newPath += n; // Check whether the directory actually exists DWORD fileAttribs = GetFileAttributes(toUnicode(newPath.c_str())); 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