diff --git a/parameterManager.h b/parameterManager.h index 9edd29f..f68dda3 100644 --- a/parameterManager.h +++ b/parameterManager.h @@ -60,7 +60,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng", genaueHoster = "", - version = "3.2.7", + version = "3.2.8", defaultFileVersion="1.6", outputFilePath = "", default_checkPath = "", diff --git a/programManager.cpp b/programManager.cpp index 2cb9042..a872d26 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -1008,14 +1008,22 @@ int ProgramManager::updateModus(Settings *settings) return 0; } + + //Download new Version of Program std::cout << " => INFO: Lade neue Version herunter..." << std::endl; std::string downloadedFilePath = settings->cacheDir + "NeusteVersion" + ((settings->pathSymbol == '\\') ? ".exe" : ""); + if(fileExists(downloadedFilePath)) + if(remove(downloadedFilePath.c_str()) != 0) { + perror("Failed to remove existing file"); + return 13; + } + if( pageManager.downLoadToFile(downloadedFilePath, settings->ProgrammFileUrl) != 0) { - std::cerr << " => Error: Download new Version failed." << std::endl; + std::cerr << "\n => Error: Download new Version failed." << std::endl; return 3; - } + } std::cout << std::endl; //Make ist executable for test execution @@ -1042,6 +1050,23 @@ int ProgramManager::updateModus(Settings *settings) return 6; } +#ifdef _WIN32 + std::cout << " => INFO: Verschiebe alte Version..." << std::endl; + if(fileExists(settings->cacheDir + "oldVersion.exe")) { + if(remove( (settings->cacheDir + "oldVersion.exe").c_str() ) != 0) { + perror("Failed to remove existing file"); + return 14; + } + } + if(rename(exePath.c_str(), (settings->cacheDir + "oldVersion.exe").c_str() ) != 0) { + perror(("Mv '" + exePath + "' -> '" + settings->cacheDir + "oldVersion.exe' failed").c_str()); + return 7; + } + +#endif + + + std::cout << " => INFO: Ersetzte alte Version mit neuer Version des Programms..." << std::endl; if(rename(downloadedFilePath.c_str(), exePath.c_str() ) != 0) {