Added --no-subdirectories option

This commit is contained in:
Sude 2014-02-23 03:16:10 +02:00
parent c70356bf49
commit 3f7669a775
3 changed files with 13 additions and 9 deletions

View File

@ -36,6 +36,7 @@ class Config
bool bSaveConfig; bool bSaveConfig;
bool bResetConfig; bool bResetConfig;
bool bReport; bool bReport;
bool bSubDirectories;
std::string sGameRegex; std::string sGameRegex;
std::string sDirectory; std::string sDirectory;
std::string sXMLFile; std::string sXMLFile;

View File

@ -111,6 +111,7 @@ int main(int argc, char *argv[])
bool bNoPatches = false; bool bNoPatches = false;
bool bNoLanguagePacks = false; bool bNoLanguagePacks = false;
bool bNoRemoteXML = false; bool bNoRemoteXML = false;
bool bNoSubDirectories = false;
// Commandline options (no config file) // Commandline options (no config file)
options_cli_no_cfg.add_options() options_cli_no_cfg.add_options()
("help,h", "Print help message") ("help,h", "Print help message")
@ -146,6 +147,7 @@ int main(int argc, char *argv[])
("no-unicode", bpo::value<bool>(&bNoUnicode)->zero_tokens()->default_value(false), "Don't use Unicode in the progress bar") ("no-unicode", bpo::value<bool>(&bNoUnicode)->zero_tokens()->default_value(false), "Don't use Unicode in the progress bar")
("no-color", bpo::value<bool>(&bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar") ("no-color", bpo::value<bool>(&bNoColor)->zero_tokens()->default_value(false), "Don't use coloring in the progress bar")
("no-duplicate-handling", bpo::value<bool>(&bNoDuplicateHandler)->zero_tokens()->default_value(false), "Don't use duplicate handler for installers\nDuplicate installers from different languages are handled separately") ("no-duplicate-handling", bpo::value<bool>(&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<bool>(&bNoSubDirectories)->zero_tokens()->default_value(false), "Don't create subdirectories for extras, patches and language packs")
("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information") ("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates") ("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take") ("timeout", bpo::value<long int>(&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.bPatches = !bNoPatches;
config.bLanguagePacks = !bNoLanguagePacks; config.bLanguagePacks = !bNoLanguagePacks;
config.bRemoteXML = !bNoRemoteXML; config.bRemoteXML = !bNoRemoteXML;
config.bSubDirectories = !bNoSubDirectories;
} }
catch (std::exception& e) catch (std::exception& e)
{ {

View File

@ -390,7 +390,7 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].extras.size(); ++j) 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); std::string url = gogAPI->getExtraLink(games[i].gamename, games[i].extras[j].id);
if (gogAPI->getError()) if (gogAPI->getError())
@ -410,7 +410,7 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].patches.size(); ++j) 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); std::string url = gogAPI->getPatchLink(games[i].gamename, games[i].patches[j].id);
if (gogAPI->getError()) if (gogAPI->getError())
@ -430,7 +430,7 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) 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); std::string url = gogAPI->getLanguagePackLink(games[i].gamename, games[i].languagepacks[j].id);
if (gogAPI->getError()) if (gogAPI->getError())
@ -520,7 +520,7 @@ void Downloader::download()
continue; 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 // Download
if (!url.empty()) if (!url.empty())
@ -553,7 +553,7 @@ void Downloader::download()
continue; 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 // Download
if (!url.empty()) if (!url.empty())
@ -586,7 +586,7 @@ void Downloader::download()
continue; 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 // Download
if (!url.empty()) if (!url.empty())
@ -1652,7 +1652,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].extras.size(); ++j) 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()); std::string localHash = this->getLocalFileHash(filepath.string());
size_t filesize; size_t filesize;
@ -1673,7 +1673,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].patches.size(); ++j) 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()); std::string localHash = this->getLocalFileHash(filepath.string());
size_t filesize; size_t filesize;
@ -1694,7 +1694,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) 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()); std::string localHash = this->getLocalFileHash(filepath.string());
size_t filesize; size_t filesize;