mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-27 00:58:51 +01:00
Preconverting %ITEM_COLLECTION_NAME% to collection name path (for merged lists).
This commit is contained in:
parent
f62c4c5e05
commit
ea8ac902a6
@ -171,18 +171,12 @@ CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name)
|
||||
std::string metadataPath;
|
||||
std::string mergedCollectionName;
|
||||
|
||||
// temporarily set currentCollection in case this is a subcollection
|
||||
conf_.getProperty("currentCollection", mergedCollectionName);
|
||||
conf_.setProperty("currentCollection", name);
|
||||
conf_.getCollectionAbsolutePath(name, listItemsPath);
|
||||
|
||||
(void)conf_.getProperty(extensionsKey, extensions);
|
||||
(void)conf_.getProperty(metadataTypeKey, metadataType);
|
||||
(void)conf_.getProperty(metadataPathKey, metadataPath);
|
||||
|
||||
// restore old collection name
|
||||
conf_.setProperty("currentCollection", mergedCollectionName);
|
||||
|
||||
if(!conf_.getProperty(launcherKey, launcherName))
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
@ -70,6 +70,11 @@ void Configuration::initialize()
|
||||
}
|
||||
|
||||
bool Configuration::import(std::string keyPrefix, std::string file)
|
||||
{
|
||||
return import("", keyPrefix, file);
|
||||
}
|
||||
|
||||
bool Configuration::import(std::string collection, std::string keyPrefix, std::string file)
|
||||
{
|
||||
bool retVal = true;
|
||||
int lineCount = 0;
|
||||
@ -89,7 +94,7 @@ bool Configuration::import(std::string keyPrefix, std::string file)
|
||||
while (std::getline (ifs, line))
|
||||
{
|
||||
lineCount++;
|
||||
retVal = retVal && parseLine(keyPrefix, line, lineCount);
|
||||
retVal = retVal && parseLine(collection, keyPrefix, line, lineCount);
|
||||
}
|
||||
|
||||
ifs.close();
|
||||
@ -97,7 +102,8 @@ bool Configuration::import(std::string keyPrefix, std::string file)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool Configuration::parseLine(std::string keyPrefix, std::string line, int lineCount)
|
||||
|
||||
bool Configuration::parseLine(std::string collection, std::string keyPrefix, std::string line, int lineCount)
|
||||
{
|
||||
bool retVal = false;
|
||||
std::string key;
|
||||
@ -127,6 +133,7 @@ bool Configuration::parseLine(std::string keyPrefix, std::string line, int lineC
|
||||
|
||||
value = line.substr(position + delimiter.length(), line.length());
|
||||
value = trimEnds(value);
|
||||
value = Utils::replace(value, "%ITEM_COLLECTION_NAME%", collection);
|
||||
|
||||
properties_.insert(PropertiesPair(key, value));
|
||||
|
||||
@ -181,15 +188,12 @@ bool Configuration::getProperty(std::string key, std::string &value)
|
||||
|
||||
std::string baseMediaPath = absolutePath;
|
||||
std::string baseItemPath = absolutePath;
|
||||
std::string collectionName;
|
||||
|
||||
getRawProperty("currentCollection", collectionName);
|
||||
getRawProperty("baseMediaPath", baseMediaPath);
|
||||
getRawProperty("baseItemPath", baseItemPath);
|
||||
|
||||
value = Utils::replace(value, "%BASE_MEDIA_PATH%", baseMediaPath);
|
||||
value = Utils::replace(value, "%BASE_ITEM_PATH%", baseItemPath);
|
||||
value = Utils::replace(value, "%ITEM_COLLECTION_NAME%", collectionName);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ public:
|
||||
static std::string convertToAbsolutePath(std::string prefix, std::string path);
|
||||
// gets the global configuration
|
||||
bool import(std::string keyPrefix, std::string file);
|
||||
bool import(std::string collection, std::string keyPrefix, std::string file);
|
||||
bool getProperty(std::string key, std::string &value);
|
||||
bool getProperty(std::string key, int &value);
|
||||
bool getProperty(std::string key, bool &value);
|
||||
@ -43,7 +44,7 @@ public:
|
||||
|
||||
private:
|
||||
bool getRawProperty(std::string key, std::string &value);
|
||||
bool parseLine(std::string keyPrefix, std::string line, int lineCount);
|
||||
bool parseLine(std::string collection, std::string keyPrefix, std::string line, int lineCount);
|
||||
std::string trimEnds(std::string str);
|
||||
typedef std::map<std::string, std::string> PropertiesType;
|
||||
typedef std::pair<std::string, std::string> PropertiesPair;
|
||||
|
||||
@ -274,17 +274,10 @@ bool Launcher::collectionDirectory(std::string &directory, std::string collectio
|
||||
std::string itemsPathValue;
|
||||
std::string mergedCollectionName;
|
||||
|
||||
// temporarily set currentCollection in case this is a subcollection
|
||||
config_.getProperty("currentCollection", mergedCollectionName);
|
||||
config_.setProperty("currentCollection", collection);
|
||||
|
||||
// find the items path folder (i.e. ROM path)
|
||||
config_.getCollectionAbsolutePath(collection, itemsPathValue);
|
||||
directory += itemsPathValue + Utils::pathSeparator;
|
||||
|
||||
// restore old collection name
|
||||
config_.setProperty("currentCollection", mergedCollectionName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -137,14 +137,14 @@ bool ImportConfiguration(Configuration *c)
|
||||
|
||||
while((dirp = readdir(dp)) != NULL)
|
||||
{
|
||||
std::string dirName = (dirp->d_name);
|
||||
if (dirp->d_type == DT_DIR && dirName != "." && dirName != ".." && dirName.length() > 0 && dirName[0] != '_')
|
||||
std::string collection = (dirp->d_name);
|
||||
if (dirp->d_type == DT_DIR && collection != "." && collection != ".." && collection.length() > 0 && collection[0] != '_')
|
||||
{
|
||||
std::string prefix = "collections." + std::string(dirp->d_name);
|
||||
std::string prefix = "collections." + collection;
|
||||
|
||||
std::string settingsFile = Utils::combinePath(collectionsPath, std::string(dirp->d_name), "settings.conf");
|
||||
std::string settingsFile = Utils::combinePath(collectionsPath, collection, "settings.conf");
|
||||
|
||||
if(!c->import(prefix, settingsFile))
|
||||
if(!c->import(collection, prefix, settingsFile))
|
||||
{
|
||||
Logger::write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + settingsFile + "\"");
|
||||
closedir(dp);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user