Added list.romHierarchy parameter to the collection's settings.conf file

with a default of false. This parameter can be used to support hierarchy in
the roms directory. Setting it to true may have an impart on the loading
time of a collection, since each rom file is checked to see if it is a
directory, and if so that directory is entered and checked as well.
This commit is contained in:
Pieter Hulshoff 2017-01-06 13:22:25 +01:00
parent b7cd765506
commit 17d65ae8fd
2 changed files with 7 additions and 5 deletions

View File

@ -285,6 +285,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
std::string launcher;
bool showMissing = false;
bool romHierarchy = false;
if (mergedCollectionName != "")
{
@ -297,6 +298,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
}
(void)conf_.getProperty("collections." + info->name + ".list.includeMissingItems", showMissing);
(void)conf_.getProperty("collections." + info->name + ".list.romHierarchy", romHierarchy);
// If no merged file exists, or it is empty, attempt to use the include and exclude from the subcollection
// If this not a merged collection, the size will be 0 anyways and the code below will still execute
@ -322,7 +324,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
// Read ROM directory if showMissing is false
if (!showMissing || includeFilter.size() == 0)
{
ImportRomDirectory(path, info, includeFilter, excludeFilter);
ImportRomDirectory(path, info, includeFilter, excludeFilter, romHierarchy);
}
while(includeFilter.size() > 0)
@ -384,7 +386,7 @@ void CollectionInfoBuilder::addFavorites(CollectionInfo *info)
}
void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter)
void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter, bool romHierarchy)
{
DIR *dp;
@ -408,9 +410,9 @@ void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo
// Check if the file is a directory or a file
struct stat sb;
if (file != "." && file != ".." && stat( Utils::combinePath( path, file ).c_str(), &sb ) == 0 && S_ISDIR( sb.st_mode ))
if (romHierarchy && file != "." && file != ".." && stat( Utils::combinePath( path, file ).c_str(), &sb ) == 0 && S_ISDIR( sb.st_mode ))
{
ImportRomDirectory( Utils::combinePath( path, file ), info, includeFilter, excludeFilter );
ImportRomDirectory( Utils::combinePath( path, file ), info, includeFilter, excludeFilter, romHierarchy );
}
else if (file != "." && file != "..")
{

View File

@ -41,5 +41,5 @@ private:
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list);
bool ImportBasicList(CollectionInfo *info, std::string file, std::vector<Item *> &list);
bool ImportDirectory(CollectionInfo *info, std::string mergedCollectionName);
void ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter);
void ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter, bool romHierarchy);
};