forked from markus/S_New4
v3.7.8: in list funktion: add debug messages
This commit is contained in:
parent
86f89f1f04
commit
53807b53f6
@ -81,7 +81,7 @@ struct Settings {
|
|||||||
proxy_ip = "127.0.0.1",
|
proxy_ip = "127.0.0.1",
|
||||||
languages = "GerDub,GerSub,Eng,",
|
languages = "GerDub,GerSub,Eng,",
|
||||||
genaueHoster = "",
|
genaueHoster = "",
|
||||||
version = "3.7.7",
|
version = "3.7.8",
|
||||||
defaultFileVersion="1.7",
|
defaultFileVersion="1.7",
|
||||||
outputFilePath = "",
|
outputFilePath = "",
|
||||||
default_checkPath = "",
|
default_checkPath = "",
|
||||||
|
@ -366,16 +366,13 @@ int ProgramManager::defaultModus(Settings *settings)
|
|||||||
//Liste alle Dateien in dem Ornder von -C auf und speichere diese
|
//Liste alle Dateien in dem Ornder von -C auf und speichere diese
|
||||||
std::string dirFiles;
|
std::string dirFiles;
|
||||||
if(settings->default_checkPath != "")
|
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)
|
if(settings->debugMode)
|
||||||
std::cerr << ">>> Debug In " << __FUNCTION__ << ": listDir failed." << std::endl;
|
std::cerr << ">>> Debug In " << __FUNCTION__ << ": listDir failed." << std::endl;
|
||||||
return 28;
|
return 28;
|
||||||
}
|
}
|
||||||
if(dirFiles.length() > 0) //Entferne von der liste das \n am ende
|
if(dirFiles.length() > 0) //Entferne von der liste das \n am ende
|
||||||
dirFiles.pop_back();
|
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
|
//Führe Function aus, die überprüft ob die serie existiert
|
||||||
std::string nameInUrl =pageManager.checkName(settings->name);
|
std::string nameInUrl =pageManager.checkName(settings->name);
|
||||||
@ -1401,10 +1398,13 @@ int ProgramManager::searchModus_update(Settings *settings)
|
|||||||
return 0;
|
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
|
//Wenn Pfad zu einem TextFile geht
|
||||||
if(fileExists(path)) {
|
if(fileExists(path)) {
|
||||||
|
if(debugMode)
|
||||||
|
std::cout << "INFO: Überprüfe Textdatei auf bereits gedownloadete Folgen (-C): '" << path << "'." << std::endl;
|
||||||
|
|
||||||
std::ifstream ifs(path);
|
std::ifstream ifs(path);
|
||||||
if(!ifs.is_open()) {
|
if(!ifs.is_open()) {
|
||||||
perror(" => Error: Konnte Textdatei nicht öffnen.");
|
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>());
|
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;
|
return 0;
|
||||||
|
|
||||||
} // Sonst normal Ordner listen
|
} // 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;
|
return 0;
|
||||||
|
}
|
||||||
else if(nothingExists(path)) {
|
else if(nothingExists(path)) {
|
||||||
std::cout << " => Warnug: Datei oder Verzeichnis existiert nicht: '" << path << "'" << std::endl;
|
std::cout << " => Warnug: Datei oder Verzeichnis existiert nicht: '" << path << "'" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1440,12 +1446,13 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DIR* dirp = opendir(path.c_str());
|
DIR* dirp = opendir(path.c_str());
|
||||||
if(!dirp) {
|
if(!dirp) {
|
||||||
perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str());
|
perror(std::string(" => Error: Konnte Verzeichnis nicht öffnen: " + path).c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if(debugMode)
|
||||||
|
std::cout << "-> Durchsuche Ordner '" << path << "'..." << std::endl;
|
||||||
|
|
||||||
struct dirent * dp;
|
struct dirent * dp;
|
||||||
while ((dp = readdir(dirp)) != nullptr) {
|
while ((dp = readdir(dirp)) != nullptr) {
|
||||||
@ -1453,9 +1460,11 @@ int ProgramManager::listDir(std::string &list,std::string path, int maxDepth)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
else if(dirExists((path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ))) { //if(dp->d_type == DT_DIR) {
|
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);
|
listDir(list, (path + dp->d_name + ((path.find("/") == std::string::npos) ? "\\" : "/") ), maxDepth, debugMode);
|
||||||
} else
|
} else {
|
||||||
list.append( std::string(dp->d_name) + "\n" );
|
list.append( std::string(dp->d_name) + "\n" );
|
||||||
|
std::cout << " > " << dp->d_name << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
ProgramManager();
|
ProgramManager();
|
||||||
~ProgramManager();
|
~ProgramManager();
|
||||||
int start(Settings *setting);
|
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:
|
private:
|
||||||
int defaultModus(Settings * settings);
|
int defaultModus(Settings * settings);
|
||||||
|
Loading…
Reference in New Issue
Block a user