From 3f7669a77588751496690de0e6193fb3b7ef1a61 Mon Sep 17 00:00:00 2001 From: Sude Date: Sun, 23 Feb 2014 03:16:10 +0200 Subject: [PATCH] Added --no-subdirectories option --- include/config.h | 1 + main.cpp | 3 +++ src/downloader.cpp | 18 +++++++++--------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/config.h b/include/config.h index 77d6efc..60ddbaf 100644 --- a/include/config.h +++ b/include/config.h @@ -36,6 +36,7 @@ class Config bool bSaveConfig; bool bResetConfig; bool bReport; + bool bSubDirectories; std::string sGameRegex; std::string sDirectory; std::string sXMLFile; diff --git a/main.cpp b/main.cpp index 1f0a361..7f36985 100644 --- a/main.cpp +++ b/main.cpp @@ -111,6 +111,7 @@ int main(int argc, char *argv[]) bool bNoPatches = false; bool bNoLanguagePacks = false; bool bNoRemoteXML = false; + bool bNoSubDirectories = false; // Commandline options (no config file) options_cli_no_cfg.add_options() ("help,h", "Print help message") @@ -146,6 +147,7 @@ int main(int argc, char *argv[]) ("no-unicode", bpo::value(&bNoUnicode)->zero_tokens()->default_value(false), "Don't use Unicode in the progress bar") ("no-color", bpo::value(&bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar") ("no-duplicate-handling", bpo::value(&bNoDuplicateHandler)->zero_tokens()->default_value(false), "Don't use duplicate handler for installers\nDuplicate installers from different languages are handled separately") + ("no-subdirectories", bpo::value(&bNoSubDirectories)->zero_tokens()->default_value(false), "Don't create subdirectories for extras, patches and language packs") ("verbose", bpo::value(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information") ("insecure", bpo::value(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates") ("timeout", bpo::value(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take") @@ -211,6 +213,7 @@ int main(int argc, char *argv[]) config.bPatches = !bNoPatches; config.bLanguagePacks = !bNoLanguagePacks; config.bRemoteXML = !bNoRemoteXML; + config.bSubDirectories = !bNoSubDirectories; } catch (std::exception& e) { diff --git a/src/downloader.cpp b/src/downloader.cpp index a676621..310538f 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -390,7 +390,7 @@ void Downloader::repair() { for (unsigned int j = 0; j < games[i].extras.size(); ++j) { - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, config.bSubDirectories ? "extras" : ""); std::string url = gogAPI->getExtraLink(games[i].gamename, games[i].extras[j].id); if (gogAPI->getError()) @@ -410,7 +410,7 @@ void Downloader::repair() { for (unsigned int j = 0; j < games[i].patches.size(); ++j) { - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, config.bSubDirectories ? "patches" : ""); std::string url = gogAPI->getPatchLink(games[i].gamename, games[i].patches[j].id); if (gogAPI->getError()) @@ -430,7 +430,7 @@ void Downloader::repair() { for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) { - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, config.bSubDirectories ? "languagepacks" : ""); std::string url = gogAPI->getLanguagePackLink(games[i].gamename, games[i].languagepacks[j].id); if (gogAPI->getError()) @@ -520,7 +520,7 @@ void Downloader::download() continue; } - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, config.bSubDirectories ? "extras" : ""); // Download if (!url.empty()) @@ -553,7 +553,7 @@ void Downloader::download() continue; } - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, config.bSubDirectories ? "patches" : ""); // Download if (!url.empty()) @@ -586,7 +586,7 @@ void Downloader::download() continue; } - std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks"); + std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, config.bSubDirectories ? "languagepacks" : ""); // Download if (!url.empty()) @@ -1652,7 +1652,7 @@ void Downloader::checkStatus() { for (unsigned int j = 0; j < games[i].extras.size(); ++j) { - boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras"); + boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, config.bSubDirectories ? "extras" : ""); std::string localHash = this->getLocalFileHash(filepath.string()); size_t filesize; @@ -1673,7 +1673,7 @@ void Downloader::checkStatus() { for (unsigned int j = 0; j < games[i].patches.size(); ++j) { - boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches"); + boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, config.bSubDirectories ? "patches" : ""); std::string localHash = this->getLocalFileHash(filepath.string()); size_t filesize; @@ -1694,7 +1694,7 @@ void Downloader::checkStatus() { for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) { - boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks"); + boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, config.bSubDirectories ? "languagepacks" : ""); std::string localHash = this->getLocalFileHash(filepath.string()); size_t filesize;