From 53807b53f6a0445be89d618614a3611c75950f79 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 22 Dec 2019 21:39:48 +0100 Subject: [PATCH] v3.7.8: in list funktion: add debug messages --- src/parameterManager.h | 2 +- src/programManager.cpp | 27 ++++++++++++++++++--------- src/programManager.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/parameterManager.h b/src/parameterManager.h index 8429d37..f50388f 100644 --- a/src/parameterManager.h +++ b/src/parameterManager.h @@ -81,7 +81,7 @@ struct Settings { proxy_ip = "127.0.0.1", languages = "GerDub,GerSub,Eng,", genaueHoster = "", - version = "3.7.7", + version = "3.7.8", defaultFileVersion="1.7", outputFilePath = "", default_checkPath = "", diff --git a/src/programManager.cpp b/src/programManager.cpp index c59ddfc..1fa2126 100644 --- a/src/programManager.cpp +++ b/src/programManager.cpp @@ -366,16 +366,13 @@ int ProgramManager::defaultModus(Settings *settings) //Liste alle Dateien in dem Ornder von -C auf und speichere diese std::string dirFiles; if(settings->default_checkPath != "") - if(listDir(dirFiles, settings->default_checkPath, settings->default_maxDirs ) != 0) { + if(listDir(dirFiles, settings->default_checkPath, settings->default_maxDirs, settings->debugMode ) != 0) { if(settings->debugMode) std::cerr << ">>> Debug In " << __FUNCTION__ << ": listDir failed." << std::endl; return 28; } if(dirFiles.length() > 0) //Entferne von der liste das \n am ende dirFiles.pop_back(); - if(settings->debugMode && settings->default_checkPath != "") //Wenn Debug Mode, gib die Liste aus - std::cout << " > [-C] Files:\n" << dirFiles << std::endl; - //Führe Function aus, die überprüft ob die serie existiert std::string nameInUrl =pageManager.checkName(settings->name); @@ -1401,10 +1398,13 @@ int ProgramManager::searchModus_update(Settings *settings) return 0; } -int ProgramManager::listDir(std::string &list,std::string path, int maxDepth) +int ProgramManager::listDir(std::string &list,std::string path, int maxDepth, bool debugMode) { //Wenn Pfad zu einem TextFile geht if(fileExists(path)) { + if(debugMode) + std::cout << "INFO: Überprüfe Textdatei auf bereits gedownloadete Folgen (-C): '" << path << "'." << std::endl; + std::ifstream ifs(path); if(!ifs.is_open()) { perror(" => Error: Konnte Textdatei nicht öffnen."); @@ -1412,11 +1412,17 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth) } list = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + if(debugMode) + std::cout << "Inhald des TextFiles (-C):\n" << list << std::endl << std::endl; + return 0; } // Sonst normal Ordner listen - else if(maxDepth <= 0) + else if(maxDepth <= 0) { + if(debugMode) + std::cout << "INFO: Brich Vorgang für '" << path << "' ab, da max. Anzahl an zu durchsuchende Ordner erreicht wurde." << std::endl; return 0; + } else if(nothingExists(path)) { std::cout << " => Warnug: Datei oder Verzeichnis existiert nicht: '" << path << "'" << std::endl; return 0; @@ -1440,12 +1446,13 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth) } } - DIR* dirp = opendir(path.c_str()); if(!dirp) { perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str()); return -1; } + if(debugMode) + std::cout << "-> Durchsuche Ordner '" << path << "'..." << std::endl; struct dirent * dp; while ((dp = readdir(dirp)) != nullptr) { @@ -1453,9 +1460,11 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth) continue; else if(dirExists((path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ))) { //if(dp->d_type == DT_DIR) { - listDir(list, (path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ), maxDepth); - } else + listDir(list, (path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ), maxDepth, debugMode); + } else { list.append( std::string(dp->d_name) + "\n" ); + std::cout << " > " << dp->d_name << std::endl; + } } closedir(dirp); return 0; diff --git a/src/programManager.h b/src/programManager.h index af8d972..985abcb 100644 --- a/src/programManager.h +++ b/src/programManager.h @@ -38,7 +38,7 @@ public: ProgramManager(); ~ProgramManager(); int start(Settings *setting); - int listDir(std::string &list, std::string path, int maxDepth); + int listDir(std::string &list, std::string path, int maxDepth, bool debugMode); private: int defaultModus(Settings * settings);