From ced671c9727ed94e19af91758ece4173d46534b3 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 30 May 2020 22:03:10 -0230 Subject: [PATCH] Some small API changes for FSNode::getChildren(); it should only include the parent if requested. --- src/emucore/FSNode.cxx | 5 +++-- src/emucore/FSNode.hxx | 3 ++- src/unix/FSNodePOSIX.cxx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index acdad37ca..0d9e53ad1 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -47,7 +47,8 @@ bool FilesystemNode::exists() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, - const NameFilter& filter) const + const NameFilter& filter, + bool includeParentDirectory) const { if (!_realNode || !_realNode->isDirectory()) return false; @@ -83,7 +84,7 @@ bool FilesystemNode::getChildren(FSList& fslist, ListMode mode, ); // Add parent node, if it is valid to do so - if (hasParent()) + if (includeParentDirectory && hasParent()) { FilesystemNode parent = getParent(); parent.setName(" [..]"); diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index 2a8acc278..16360cafe 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -134,7 +134,8 @@ class FilesystemNode * does not exist). */ bool getChildren(FSList& fslist, ListMode mode = ListMode::DirectoriesOnly, - const NameFilter& filter = [](const FilesystemNode&){ return true; }) const; + const NameFilter& filter = [](const FilesystemNode&){ return true; }, + bool includeParentDirectory = true) const; /** * Set/get a string representation of the name of the file. This is can be diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index 33f6b5226..f483dc899 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -159,7 +159,7 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) con if (entry._isDirectory) entry._path += "/"; - entry._isValid = entry._isDirectory || entry._isFile; + entry._isValid = true; } #endif