Added support for collection's info.conf file in addition to the settings.conf. This file should be used to provide additional system information, and will overwrite similar settings in settings.conf. This feature is merely intended to allow a user to keep the settings separated from the system information.

This commit is contained in:
Pieter Hulshoff 2016-07-20 15:30:23 +02:00
parent 46200f029d
commit d3d4bdcd41
4 changed files with 15 additions and 6 deletions

View File

@ -121,9 +121,6 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
settingsFile << "launcher = mame" << std::endl;
settingsFile << "#metadata.type = MAME" << std::endl;
settingsFile << std::endl;
settingsFile << "#manufacturer = " << std::endl;
settingsFile << "#year = " << std::endl;
settingsFile << "#genre = " << std::endl;
settingsFile << std::endl;
settingsFile << "#media.screenshot = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screenshot") << std::endl;
settingsFile << "#media.screentitle = " << Utils::combinePath("%BASE_MEDIA_PATH%", "%ITEM_COLLECTION_NAME%", "medium_artwork", "screentitle") << std::endl;

View File

@ -74,7 +74,7 @@ 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 Configuration::import(std::string collection, std::string keyPrefix, std::string file, bool mustExist)
{
bool retVal = true;
int lineCount = 0;
@ -86,7 +86,14 @@ bool Configuration::import(std::string collection, std::string keyPrefix, std::s
if (!ifs.is_open())
{
Logger::write(Logger::ZONE_ERROR, "Configuration", "Could not open " + file + "\"");
if (mustExist)
{
Logger::write(Logger::ZONE_ERROR, "Configuration", "Could not open " + file + "\"");
}
else
{
Logger::write(Logger::ZONE_INFO, "Configuration", "Could not open " + file + "\"");
}
return false;
}

View File

@ -28,7 +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 import(std::string collection, std::string keyPrefix, std::string file, bool mustExist = true);
bool getProperty(std::string key, std::string &value);
bool getProperty(std::string key, int &value);
bool getProperty(std::string key, bool &value);

View File

@ -146,6 +146,10 @@ bool ImportConfiguration(Configuration *c)
{
std::string prefix = "collections." + collection;
std::string infoFile = Utils::combinePath(collectionsPath, collection, "info.conf");
c->import(collection, prefix, infoFile, false);
std::string settingsFile = Utils::combinePath(collectionsPath, collection, "settings.conf");
if(!c->import(collection, prefix, settingsFile))
@ -154,6 +158,7 @@ bool ImportConfiguration(Configuration *c)
closedir(dp);
return false;
}
}
}