From fc88679b1209618c84d486a0c4f6264650ec7d01 Mon Sep 17 00:00:00 2001 From: Sude Date: Thu, 4 Feb 2016 11:51:11 +0200 Subject: [PATCH] Add option to set automatic XML creation in config file --- include/config.h | 1 + main.cpp | 4 ++++ src/downloader.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/config.h b/include/config.h index ea6fe6c..0bedfe6 100644 --- a/include/config.h +++ b/include/config.h @@ -46,6 +46,7 @@ class Config bool bSaveSerials; bool bPlatformDetection; bool bShowWishlist; + bool bAutomaticXMLCreation; std::string sGameRegex; std::string sDirectory; std::string sCacheDirectory; diff --git a/main.cpp b/main.cpp index dcbb184..b521f67 100644 --- a/main.cpp +++ b/main.cpp @@ -192,6 +192,7 @@ int main(int argc, char *argv[]) ("ignore-dlc-count", bpo::value(&config.sIgnoreDLCCountRegex)->implicit_value(".*"), "Set regular expression filter for games to ignore DLC count information\nIgnoring DLC count information helps in situations where the account page doesn't provide accurate information about DLCs") ("include", bpo::value(&sIncludeOptions)->default_value("all"), ("Select what to download/list/repair\n" + include_options_text).c_str()) ("exclude", bpo::value(&sExcludeOptions)->default_value("covers"), ("Select what not to download/list/repair\n" + include_options_text).c_str()) + ("automatic-xml-creation", bpo::value(&config.bAutomaticXMLCreation)->zero_tokens()->default_value(false), "Automatically create XML data after download has completed") ; // Options read from config file options_cfg_only.add_options() @@ -338,6 +339,9 @@ int main(int argc, char *argv[]) config.bLoginHTTP = true; } + if (config.sXMLFile == "automatic") + config.bAutomaticXMLCreation = true; + parseOptionString(sInstallerLanguage, config.vLanguagePriority, config.iInstallerLanguage, GlobalConstants::LANGUAGES); parseOptionString(sInstallerPlatform, config.vPlatformPriority, config.iInstallerPlatform, GlobalConstants::PLATFORMS); diff --git a/src/downloader.cpp b/src/downloader.cpp index 9a5ed31..25289d5 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -922,7 +922,7 @@ void Downloader::download() std::cout << filepath << std::endl; CURLcode result = this->downloadFile(url, filepath); std::cout << std::endl; - if (result==CURLE_OK && config.sXMLFile == "automatic") + if (result==CURLE_OK && config.bAutomaticXMLCreation) { std::cout << "Starting automatic XML creation" << std::endl; std::string xml_dir = config.sXMLDirectory + "/" + games[i].gamename; @@ -1144,7 +1144,7 @@ void Downloader::download() std::cout << "Dowloading: " << games[i].dlcs[j].extras[k].name << std::endl; CURLcode result = this->downloadFile(url, filepath); std::cout << std::endl; - if (result==CURLE_OK && config.sXMLFile == "automatic") + if (result==CURLE_OK && config.bAutomaticXMLCreation) { std::cout << "Starting automatic XML creation" << std::endl; std::string xml_dir = config.sXMLDirectory + "/" + games[i].dlcs[j].gamename; @@ -1462,7 +1462,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, { bLocalXMLExists = boost::filesystem::exists(xml_file); // Check to see if downloadFile saved XML data - if (config.sXMLFile == "automatic" && !bLocalXMLExists) + if (config.bAutomaticXMLCreation && !bLocalXMLExists) { std::cout << "Starting automatic XML creation" << std::endl; Util::createXML(filepath, config.iChunkSize, xml_directory); @@ -1503,7 +1503,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, std::cout << std::endl; if (result == CURLE_OK) { - if (config.sXMLFile == "automatic" && bParsingFailed) + if (config.bAutomaticXMLCreation && bParsingFailed) { std::cout << "Starting automatic XML creation" << std::endl; Util::createXML(filepath, config.iChunkSize, xml_directory);