diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 57233f33a..9849a684b 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -211,7 +211,6 @@ const std::string FileData::getMediaDirectory() const std::string FileData::getMediafilePath(const std::string& subdirectory) const { - const std::vector extList {".png", ".jpg"}; std::string subFolders; // Extract possible subfolders from the path. @@ -223,8 +222,8 @@ const std::string FileData::getMediafilePath(const std::string& subdirectory) co subFolders + "/" + getDisplayName()}; // Look for an image file in the media directory. - for (size_t i {0}; i < extList.size(); ++i) { - std::string mediaPath {tempPath + extList[i]}; + for (auto& extension : sImageExtensions) { + const std::string mediaPath {tempPath + extension}; if (Utils::FileSystem::exists(mediaPath)) return mediaPath; } @@ -316,7 +315,6 @@ const std::string FileData::getCustomImagePath() const const std::string FileData::getVideoPath() const { - const std::vector extList {".avi", ".mkv", ".mov", ".mp4", ".wmv"}; std::string subFolders; // Extract possible subfolders from the path. @@ -328,8 +326,8 @@ const std::string FileData::getVideoPath() const getDisplayName()}; // Look for media in the media directory. - for (size_t i {0}; i < extList.size(); ++i) { - std::string mediaPath {tempPath + extList[i]}; + for (auto& extension : sVideoExtensions) { + const std::string mediaPath {tempPath + extension}; if (Utils::FileSystem::exists(mediaPath)) return mediaPath; } diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 4940d3aa9..a12e5613d 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -40,11 +40,7 @@ public: const std::string& getName() { return metadata.get("name"); } const std::string& getSortName(); // Returns our best guess at the "real" name for this file. - std::string getDisplayName() const - { - const std::string& stem {Utils::FileSystem::getStem(mPath)}; - return stem; - } + std::string getDisplayName() const { return Utils::FileSystem::getStem(mPath); } std::string getCleanName() const { return Utils::String::removeParenthesis(this->getDisplayName()); @@ -112,8 +108,8 @@ public: bool excludeRecursively, bool respectExclusions) const; - void addChild(FileData* file); // Error if mType != FOLDER - void removeChild(FileData* file); // Error if mType != FOLDER + void addChild(FileData* file); + void removeChild(FileData* file); virtual std::string getKey() { return getFileName(); } const bool isArcadeAsset() const; @@ -175,6 +171,9 @@ private: std::vector mChildrenLastPlayed; std::vector mChildrenMostPlayed; std::function mUpdateListCallback; + static inline std::vector sImageExtensions {".png", ".jpg"}; + static inline std::vector sVideoExtensions {".mp4", ".mkv", ".avi", + ".mp4", ".wmv", ".mov"}; // The pair includes all games, and favorite games. std::pair mGameCount; bool mOnlyFolders;