Minor changes to some media lookup functions

This commit is contained in:
Leon Styhre 2023-12-18 22:55:59 +01:00
parent 97d26718a3
commit c3747d4e51
2 changed files with 10 additions and 13 deletions

View file

@ -211,7 +211,6 @@ const std::string FileData::getMediaDirectory()
const std::string FileData::getMediafilePath(const std::string& subdirectory) const
{
const std::vector<std::string> 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<std::string> 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;
}

View file

@ -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<FileData*> mChildrenLastPlayed;
std::vector<FileData*> mChildrenMostPlayed;
std::function<void()> mUpdateListCallback;
static inline std::vector<std::string> sImageExtensions {".png", ".jpg"};
static inline std::vector<std::string> sVideoExtensions {".mp4", ".mkv", ".avi",
".mp4", ".wmv", ".mov"};
// The pair includes all games, and favorite games.
std::pair<unsigned int, unsigned int> mGameCount;
bool mOnlyFolders;