diff --git a/parameterManager.h b/parameterManager.h index 6b565c0..5fc1e1d 100644 --- a/parameterManager.h +++ b/parameterManager.h @@ -47,7 +47,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng", genaueHoster = "", - version = "2.8.3", + version = "2.9.0", defaultFileVersion="1.3", outputFilePath = "", default_checkPath = "", diff --git a/programManager.cpp b/programManager.cpp index 7e18833..c611d77 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -744,47 +744,51 @@ int ProgramManager::searchModus_update(Settings *settings) //Anzahl der Serien/Zeilen vorher: ssize_t countBef = 0; std::ifstream myFileBef(settings->serienListPath); - if(myFileBef.is_open()) - for(countBef = 0; std::getline(myFileBef,line); ++countBef); - myFileBef.close(); + std::string alteListe; + if(myFileBef.is_open()) { + for(countBef = 0; std::getline(myFileBef,line); ++countBef) { + //Speicher alteListe für verglkeich nach Update + alteListe.append(line + "\n"); - //Speicher für Vergleich Alte liste: - std::ifstream t(settings->serienListPath); - if(!t.is_open()) { + //Vergeliche neue und alte list => entfernte Serien + if(line != "" && serienListe.find(line) == std::string::npos) { + std::cout << ((settings->colorless) ? "" : "\033[91m") << "Entfernt: '" << line.substr(line.find_last_of("|") + 1) << "'" << "\033[0m" << std::endl; + } + } + myFileBef.close(); + } else { perror("Konnte SerienListe-Datei nicht öffnen"); return 110; } - std::string alte_list((std::istreambuf_iterator(t)), - std::istreambuf_iterator()); - t.close(); //Schreibe die Liste in das TextFile std::ofstream ofs(settings->serienListPath, std::ios::trunc); if(!ofs.is_open()) { perror("Konnte SerienListe-Datei nicht öffnen"); return 111; + } else { + //Schreibe Liste in das TextFile + ofs << serienListe << std::endl; + ofs.close(); } - ofs << serienListe << std::endl; - ofs.close(); //Anzahl der Zeile nachher ssize_t countAf = 0; std::ifstream myFileAf(settings->serienListPath); - if(myFileAf.is_open()) - for(countAf = 0; std::getline(myFileAf,line); ++countAf); - myFileAf.close(); - - - //Vergleiche alte/Neue Liste: - - std::stringstream newStrStr(serienListe.c_str()); - while (std::getline(newStrStr, line).good()) { - if(line != "" && alte_list.find(line) == std::string::npos) { - std::cout << "Neu: '" << line.substr(line.find_last_of("|") + 1) << "'" << std::endl; + if(myFileAf.is_open()) { + for(countAf = 0; std::getline(myFileAf,line); ++countAf) { + //Vergeliche neu mit Alt => gib neue Serien aus + if(line != "" && alteListe.find(line) == std::string::npos) { + std::cout << ((settings->colorless) ? "" : "\033[92m") << "Neu: '" << line.substr(line.find_last_of("|") + 1) << "'" << "\033[0m" << std::endl; + } } + myFileAf.close(); + } else { + perror("Konnte SerienListe-Datei nicht öffnen"); + return 112; } - std::cout << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << std::endl; + std::cout << ((settings->colorless) ? "" : "\033[93m") << "Serienunterschied: " << ( ((countAf - countBef) > 0) ? "+" : "") << countAf - countBef << " Serien." << "\033[0m" << std::endl; return 0; }