Refactored CreateLOOTGameFolder() into Game class.

Since it was the only GameSettings member that modified the filesystem,
as was only called from in Game anyway.
This commit is contained in:
Oliver Hamlet
2015-07-12 18:37:13 +01:00
parent 7aa84d5276
commit 2db5519375
4 changed files with 15 additions and 13 deletions
+12
View File
@@ -200,6 +200,18 @@ namespace loot {
return false;
}
void Game::CreateLOOTGameFolder() {
//Make sure that the LOOT game path exists.
try {
if (fs::exists(g_path_local) && !fs::exists(g_path_local / _lootFolderName))
fs::create_directory(g_path_local / _lootFolderName);
}
catch (fs::filesystem_error& e) {
BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what();
throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what());
}
}
std::list<Game> ToGames(const std::list<GameSettings>& settings) {
return list<Game>(settings.begin(), settings.end());
}
+3
View File
@@ -73,6 +73,9 @@ namespace loot {
Masterlist masterlist;
MetadataList userlist;
std::unordered_map<std::string, Plugin> plugins; //Map so that plugin data can be edited.
private:
//Creates directory in LOOT folder for LOOT's game-specific files.
void CreateLOOTGameFolder();
};
std::list<Game> ToGames(const std::list<GameSettings>& settings);
-10
View File
@@ -201,16 +201,6 @@ namespace loot {
return g_path_local / _lootFolderName / "userlist.yaml";
}
void GameSettings::CreateLOOTGameFolder() {
//Make sure that the LOOT game path exists.
try {
if (fs::exists(g_path_local) && !fs::exists(g_path_local / _lootFolderName))
fs::create_directory(g_path_local / _lootFolderName);
}
catch (fs::filesystem_error& e) {
BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what();
throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what());
}
}
std::list<GameSettings> GetGameSettings(YAML::Node& settings) {
-3
View File
@@ -66,9 +66,6 @@ namespace loot {
static const unsigned int tes5;
static const unsigned int fo3;
static const unsigned int fonv;
protected:
//Creates directory in LOOT folder for LOOT's game-specific files.
void CreateLOOTGameFolder();
private:
unsigned int _id;
std::string _name;