diff options
Diffstat (limited to 'backends/fs')
-rw-r--r-- | backends/fs/abstract-fs.h | 2 | ||||
-rw-r--r-- | backends/fs/amigaos4/amigaos4-fs.cpp | 15 | ||||
-rw-r--r-- | backends/fs/fs.cpp | 20 | ||||
-rw-r--r-- | backends/fs/fs.h | 7 | ||||
-rw-r--r-- | backends/fs/morphos/abox-fs.cpp | 13 | ||||
-rw-r--r-- | backends/fs/palmos/palmos-fs.cpp | 9 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 9 | ||||
-rw-r--r-- | backends/fs/ps2/ps2-fs.cpp | 8 | ||||
-rw-r--r-- | backends/fs/symbian/symbian-fs.cpp | 7 | ||||
-rw-r--r-- | backends/fs/windows/windows-fs.cpp | 10 |
10 files changed, 48 insertions, 52 deletions
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index a01ad11c69..d6229a992c 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -88,7 +88,7 @@ public: virtual bool isValid() const = 0; virtual bool isDirectory() const = 0; virtual String path() const = 0; - virtual AbstractFSList listDir(ListMode mode) const = 0; + virtual bool listDir(AbstractFSList &list, ListMode mode) const = 0; /* TODO: diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index 2be79012ec..cc7220c9b1 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -69,7 +69,7 @@ class AmigaOSFilesystemNode : public AbstractFilesystemNode { virtual bool isDirectory() const { return _bIsDirectory; }; virtual String path() const { return _sPath; }; - virtual AbstractFSList listDir(ListMode mode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFSList listVolumes(void) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; @@ -222,27 +222,26 @@ AmigaOSFilesystemNode::~AmigaOSFilesystemNode() { LEAVE(); } -AbstractFSList AmigaOSFilesystemNode::listDir(ListMode mode) const { +bool AmigaOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { ENTER(); - AbstractFSList myList; - if (!_bIsValid) { debug(6, "Invalid node"); LEAVE(); - return myList; // Empty list + return false; // Empty list } if (!_bIsDirectory) { debug(6, "Not a directory"); LEAVE(); - return myList; // Empty list + return false; // Empty list } if (_pFileLock == 0) { debug(6, "Root node"); LEAVE(); - return listVolumes(); + myList = listVolumes(); + return true; } struct ExAllControl *eac = (struct ExAllControl *)IDOS->AllocDosObject(DOS_EXALLCONTROL, 0); @@ -293,7 +292,7 @@ AbstractFSList AmigaOSFilesystemNode::listDir(ListMode mode) const { } LEAVE(); - return myList; + return true; } AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const { diff --git a/backends/fs/fs.cpp b/backends/fs/fs.cpp index f7844fb66a..12cdc145ba 100644 --- a/backends/fs/fs.cpp +++ b/backends/fs/fs.cpp @@ -99,17 +99,21 @@ FilesystemNode FilesystemNode::getChild(const String &name) const { return FilesystemNode(node); } -FSList FilesystemNode::listDir(ListMode mode) const { - assert(_realNode); - assert(_realNode->isDirectory()); - AbstractFSList inList(_realNode->listDir(mode)); - FSList outList; +bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const { + if (!_realNode || !_realNode->isDirectory()) + return false; + + AbstractFSList tmp; + + if (!_realNode->listDir(tmp, mode)) + return false; - for (AbstractFSList::iterator i = inList.begin(); i != inList.end(); ++i) { - outList.push_back(FilesystemNode(*i)); + fslist.clear(); + for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) { + fslist.push_back(FilesystemNode(*i)); } - return outList; + return true; } Common::String FilesystemNode::displayName() const { diff --git a/backends/fs/fs.h b/backends/fs/fs.h index 38b46db031..f2930bd375 100644 --- a/backends/fs/fs.h +++ b/backends/fs/fs.h @@ -106,11 +106,12 @@ public: FilesystemNode getChild(const String &name) const; /** - * Return a list of child nodes of this directory node. If called - * on a node that does not represent a directory, an error is triggered. + * Return a list of child nodes of this directory node. If called on a node + * that does not represent a directory, false is returned. + * @return true if succesful, false otherwise (e.g. when the directory does not exist). * @todo Rename this to listChildren or getChildren. */ - virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const; + virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const; /** * Return a human readable string for this node, usable for display (e.g. diff --git a/backends/fs/morphos/abox-fs.cpp b/backends/fs/morphos/abox-fs.cpp index 70234740d3..38e84b2547 100644 --- a/backends/fs/morphos/abox-fs.cpp +++ b/backends/fs/morphos/abox-fs.cpp @@ -51,7 +51,7 @@ class ABoxFilesystemNode : public AbstractFilesystemNode { virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode mode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; static AbstractFSList listRoot(); virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; @@ -129,10 +129,8 @@ ABoxFilesystemNode::~ABoxFilesystemNode() } } -AbstractFSList ABoxFilesystemNode::listDir(ListMode mode) const +bool ABoxFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { - AbstractFSList myList; - if (!_isValid) error("listDir() called on invalid node"); @@ -142,7 +140,8 @@ AbstractFSList ABoxFilesystemNode::listDir(ListMode mode) const if (_lock == NULL) { /* This is the root node */ - return listRoot(); + myList = listRoot(); + return true; } /* "Normal" file system directory */ @@ -151,7 +150,7 @@ AbstractFSList ABoxFilesystemNode::listDir(ListMode mode) const if (fib == NULL) { warning("Failed to allocate memory for FileInfoBlock"); - return myList; + return false; } if (Examine(_lock, fib) != DOSFALSE) @@ -189,7 +188,7 @@ AbstractFSList ABoxFilesystemNode::listDir(ListMode mode) const FreeDosObject(DOS_FIB, fib); - return myList; + return tree; } AbstractFilesystemNode *ABoxFilesystemNode::parent() const diff --git a/backends/fs/palmos/palmos-fs.cpp b/backends/fs/palmos/palmos-fs.cpp index 4bbe8e383f..20480e9a14 100644 --- a/backends/fs/palmos/palmos-fs.cpp +++ b/backends/fs/palmos/palmos-fs.cpp @@ -48,7 +48,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; @@ -116,8 +116,7 @@ PalmOSFilesystemNode::PalmOSFilesystemNode(const PalmOSFilesystemNode &node) { _path = node._path; } -AbstractFSList PalmOSFilesystemNode::listDir(ListMode mode) const { - AbstractFSList myList; +bool PalmOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { Err e; Char nameP[256]; FileInfoType desc; @@ -129,7 +128,7 @@ AbstractFSList PalmOSFilesystemNode::listDir(ListMode mode) const { e = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle); if (e) - return myList; + return false; while(dirIterator != expIteratorStop) { e = VFSDirEntryEnumerate(handle, &dirIterator, &desc); @@ -140,7 +139,7 @@ AbstractFSList PalmOSFilesystemNode::listDir(ListMode mode) const { VFSFileClose(handle); - return myList; + return true; } const char *lastPathComponent(const Common::String &str) { diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 86ca581fd1..b9278fbb00 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -57,7 +57,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode mode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; }; @@ -136,15 +136,14 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) { } } -AbstractFSList POSIXFilesystemNode::listDir(ListMode mode) const { +bool POSIXFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { assert(_isDirectory); DIR *dirp = opendir(_path.c_str()); struct dirent *dp; - AbstractFSList myList; if (dirp == NULL) - return myList; + return false; // ... loop over dir entries using readdir while ((dp = readdir(dirp)) != NULL) { @@ -201,7 +200,7 @@ AbstractFSList POSIXFilesystemNode::listDir(ListMode mode) const { myList.push_back(new POSIXFilesystemNode(entry)); } closedir(dirp); - return myList; + return true; } AbstractFilesystemNode *POSIXFilesystemNode::parent() const { diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp index 980df347af..7370c3393e 100644 --- a/backends/fs/ps2/ps2-fs.cpp +++ b/backends/fs/ps2/ps2-fs.cpp @@ -45,7 +45,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; @@ -79,11 +79,9 @@ Ps2FilesystemNode::Ps2FilesystemNode(const String &path) { _isDirectory = true; } -AbstractFSList Ps2FilesystemNode::listDir(ListMode mode) const { +bool Ps2FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { assert(_isDirectory); - AbstractFSList myList; - struct TocEntry tocEntries[MAX_LIST_ENTRIES]; int files; char listDir[512]; @@ -115,7 +113,7 @@ AbstractFSList Ps2FilesystemNode::listDir(ListMode mode) const { myList.push_back(new Ps2FilesystemNode(dirEntry)); } } - return myList; + return true; } AbstractFilesystemNode *Ps2FilesystemNode::parent() const { diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 948c86372e..e73c4d4489 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -52,7 +52,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode mode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; }; @@ -105,9 +105,8 @@ SymbianFilesystemNode::SymbianFilesystemNode(const String &path) { _isDirectory = true; } -AbstractFSList SymbianFilesystemNode::listDir(ListMode mode) const { +bool SymbianFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { assert(_isDirectory); - AbstractFSList myList; if (_isPseudoRoot) { // Drives enumeration @@ -179,7 +178,7 @@ AbstractFSList SymbianFilesystemNode::listDir(ListMode mode) const { } } - return myList; + return true; } AbstractFilesystemNode *SymbianFilesystemNode::parent() const { diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 0f01fda280..250953b064 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -50,7 +50,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual AbstractFSList listDir(ListMode) const; + virtual bool listDir(AbstractFSList &list, ListMode mode) const; virtual AbstractFilesystemNode *parent() const; virtual AbstractFilesystemNode *child(const String &name) const; @@ -163,11 +163,9 @@ WindowsFilesystemNode::WindowsFilesystemNode(const String &p) { _isPseudoRoot = false; } -AbstractFSList WindowsFilesystemNode::listDir(ListMode mode) const { +bool WindowsFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const { assert(_isDirectory); - AbstractFSList myList; - if (_isPseudoRoot) { #ifndef _WIN32_WCE // Drives enumeration @@ -200,7 +198,7 @@ AbstractFSList WindowsFilesystemNode::listDir(ListMode mode) const { handle = FindFirstFile(toUnicode(searchPath), &desc); if (handle == INVALID_HANDLE_VALUE) - return myList; + return false; addFile(myList, mode, _path.c_str(), &desc); while (FindNextFile(handle, &desc)) addFile(myList, mode, _path.c_str(), &desc); @@ -208,7 +206,7 @@ AbstractFSList WindowsFilesystemNode::listDir(ListMode mode) const { FindClose(handle); } - return myList; + return true; } AbstractFilesystemNode *WindowsFilesystemNode::parent() const { |