From 94d01ba7a3e1fb93856ae9a0bedb1becbed210ae Mon Sep 17 00:00:00 2001 From: Ruediger Hanke Date: Wed, 20 Nov 2002 13:25:22 +0000 Subject: Implemented mode parameter for listDir() svn-id: r5640 --- backends/fs/morphos/abox-fs.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'backends/fs/morphos') diff --git a/backends/fs/morphos/abox-fs.cpp b/backends/fs/morphos/abox-fs.cpp index 6cc53a7b54..9bd3c99be8 100644 --- a/backends/fs/morphos/abox-fs.cpp +++ b/backends/fs/morphos/abox-fs.cpp @@ -50,7 +50,7 @@ class ABoxFilesystemNode : public FilesystemNode { virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual FSList *listDir() const; + virtual FSList *listDir(ListMode mode = kListDirectoriesOnly) const; static FSList *listRoot(); virtual FilesystemNode *parent() const; virtual FilesystemNode *clone() const { return new ABoxFilesystemNode(this); } @@ -137,10 +137,10 @@ ABoxFilesystemNode::~ABoxFilesystemNode() } } -FSList *ABoxFilesystemNode::listDir() const +FSList *ABoxFilesystemNode::listDir(ListMode mode) const { FSList *myList = new FSList(); - + if (!_isValid) error("listDir() called on invalid node"); @@ -170,19 +170,23 @@ FSList *ABoxFilesystemNode::listDir() const String full_path; BPTR lock; - full_path = _path; - full_path += fib->fib_FileName; - lock = Lock(full_path.c_str(), SHARED_LOCK); - if (lock) + if ((fib->fib_EntryType > 0 && (mode & kListDirectoriesOnly)) || + (fib->fib_EntryType < 0 && (mode & kListFilesOnly))) { - entry = new ABoxFilesystemNode(lock); - if (entry) + full_path = _path; + full_path += fib->fib_FileName; + lock = Lock(full_path.c_str(), SHARED_LOCK); + if (lock) { - if (entry->isValid()) - myList->push_back(*entry); - delete entry; + entry = new ABoxFilesystemNode(lock); + if (entry) + { + if (entry->isValid()) + myList->push_back(*entry); + delete entry; + } + UnLock(lock); } - UnLock(lock); } } @@ -237,9 +241,9 @@ FSList *ABoxFilesystemNode::listRoot() dosList = NextDosEntry(dosList, LDF_VOLUMES); while (dosList) { - if (dosList->dol_Type == DLT_VOLUME && // Should always be true, but ... - dosList->dol_Name && // Same here - dosList->dol_Task // Will be NULL if volume is removed from drive but still in use by some program + if (dosList->dol_Type == DLT_VOLUME && // Should always be true, but ... + dosList->dol_Name && // Same here + dosList->dol_Task // Will be NULL if volume is removed from drive but still in use by some program ) { ABoxFilesystemNode *entry; @@ -273,3 +277,4 @@ FSList *ABoxFilesystemNode::listRoot() #endif // defined(__MORPHOS__) + -- cgit v1.2.3