We don't need to check for directory, since we're using FSNode::ListMode::FilesOnly.

This commit is contained in:
Stephen Anthony 2022-08-13 21:24:03 -02:30
parent 8f8efafd98
commit 477c800d0e
2 changed files with 18 additions and 20 deletions

View File

@ -187,10 +187,12 @@ bool RomImageWidget::getImageList(const string& propname, const string& filename
FSNode::NameFilter filter = ([&](const FSNode& node)
{
const string& nodeName = node.getName();
return (!node.isDirectory() &&
return
(nodeName == pngPropName || nodeName == pngFileName ||
(nodeName.find(propname + " #") == 0 && nodeName.find(".png") == nodeName.length() - 4) ||
(nodeName.find(filename + " #") == 0 && nodeName.find(".png") == nodeName.length() - 4)));
(nodeName.find(propname + " #") == 0 &&
nodeName.find(".png") == nodeName.length() - 4) ||
(nodeName.find(filename + " #") == 0 &&
nodeName.find(".png") == nodeName.length() - 4));
}
);
@ -198,7 +200,8 @@ bool RomImageWidget::getImageList(const string& propname, const string& filename
FSNode node(instance().snapshotLoadDir().getPath());
node.getChildren(myImageList, FSNode::ListMode::FilesOnly, filter, false, false);
// Sort again, not considering extensions, else <filename.png> would be at the end of the list
// Sort again, not considering extensions, else <filename.png> would be at
// the end of the list
std::sort(myImageList.begin(), myImageList.end(),
[](const FSNode& node1, const FSNode& node2)
{

View File

@ -15,6 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "TimerManager.hxx"
#if defined(RETRON77)
#define ROOT_DIR "/mnt/games/"
#else
@ -101,7 +103,10 @@ bool FSNodePOSIX::hasParent() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
{
assert(_isDirectory);
uInt64 T = TimerManager::getTicks();
if (!_isDirectory)
return false;
DIR* dirp = opendir(_path.c_str());
if (dirp == nullptr)
@ -122,16 +127,6 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
FSNodePOSIX entry(newPath, false);
#if defined(SYSTEM_NOT_SUPPORTING_D_TYPE)
/* TODO: d_type is not part of POSIX, so it might not be supported
* on some of our targets. For those systems where it isn't supported,
* add this #elif case, which tries to use stat() instead.
*
* The d_type method is used to avoid costly recurrent stat() calls in big
* directories.
*/
entry.setFlags();
#else
if (dp->d_type == DT_UNKNOWN)
{
// Fall back to stat()
@ -161,7 +156,6 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
entry._isValid = true;
}
#endif
// Skip files that are invalid for some reason (e.g. because we couldn't
// properly stat them).
@ -177,6 +171,7 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
}
closedir(dirp);
cerr << (TimerManager::getTicks() - T) << endl;
return true;
}