v3.7.8: in list funktion: add debug messages

This commit is contained in:
Markus 2019-12-22 21:39:48 +01:00
parent 86f89f1f04
commit 53807b53f6
3 changed files with 20 additions and 11 deletions

View File

@ -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 = "",

View File

@ -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<char>(ifs)), std::istreambuf_iterator<char>());

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;

View File

@ -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);