forked from markus/S_New4
v2.9.0 add info new and deleted serien when update searchlist with colormode
This commit is contained in:
parent
1eed669a8f
commit
61772afeb8
@ -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 = "",
|
||||
|
@ -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<char>(t)),
|
||||
std::istreambuf_iterator<char>());
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user