From 477c800d0e77554ba2be03780ea561ee845c0e5f Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 13 Aug 2022 21:24:03 -0230 Subject: [PATCH] We don't need to check for directory, since we're using FSNode::ListMode::FilesOnly. --- src/gui/RomImageWidget.cxx | 19 +++++++++++-------- src/unix/FSNodePOSIX.cxx | 19 +++++++------------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 7919362e6..23a513902 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -89,9 +89,9 @@ void RomImageWidget::parseProperties(const FSNode& node, bool complete) FBSurface::Attributes& attr = myNavSurface->attributes(); attr.blending = true; - attr.blendalpha = 60; + attr.blendalpha = 60; myNavSurface->applyAttributes(); - } + } // Check if a surface has ever been created; if so, we use it // The surface will always be the maximum size, but sometimes we'll @@ -122,7 +122,7 @@ void RomImageWidget::parseProperties(const FSNode& node, bool complete) // Get a valid filename representing a snapshot file for this rom and load the snapshot myImageList.clear(); myImageIdx = 0; - + if(complete) { // Try to load snapshots by property name and ROM file name @@ -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 would be at the end of the list + // Sort again, not considering extensions, else would be at + // the end of the list std::sort(myImageList.begin(), myImageList.end(), [](const FSNode& node1, const FSNode& node2) { @@ -221,7 +224,7 @@ bool RomImageWidget::loadPng(const string& filename) const float scale = std::min(float(_w) / src.w(), float(myImageHeight) / src.h()) * instance().frameBuffer().hidpiScaleFactor(); mySurface->setDstSize(static_cast(src.w() * scale), static_cast(src.h() * scale)); - + // Retrieve label for loaded image myLabel = ""; for(auto comment = comments.begin(); comment != comments.end(); ++comment) diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index de143da54..703460e29 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -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; }