From e0636db60d003d1a4444978ba3a08c3fbb4923fe Mon Sep 17 00:00:00 2001 From: Zach H Date: Thu, 8 Dec 2016 05:00:44 -0500 Subject: [PATCH] Recursively search CUSTOM folder for images (i.e. subdirectories) (#2251) --- cockatrice/src/pictureloader.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/pictureloader.cpp b/cockatrice/src/pictureloader.cpp index 973b81ab..39944b1b 100644 --- a/cockatrice/src/pictureloader.cpp +++ b/cockatrice/src/pictureloader.cpp @@ -19,6 +19,7 @@ #include #include #include +#include // never cache more than 300 cards at once for a single deck #define CACHED_CARD_PER_DECK_MAX 300 @@ -167,9 +168,18 @@ bool PictureLoaderWorker::cardImageExistsOnDisk(QString & setName, QString & cor QImage image; QImageReader imgReader; imgReader.setDecideFormatFromContent(true); + QList picsPaths = QList(); + QDirIterator it(customPicsPath, QDirIterator::Subdirectories); - //The list of paths to the folders in which to search for images - QList picsPaths = QList() << customPicsPath + correctedCardname; + // Recursively check all subdirectories of the CUSTOM folder + while (it.hasNext()) + { + QString thisPath(it.next()); + QFileInfo thisFileInfo(thisPath); + + if (thisFileInfo.isFile() && thisFileInfo.baseName() == correctedCardname) + picsPaths << thisPath; // Card found in the CUSTOM directory, somewhere + } if(!setName.isEmpty()) {