diff --git a/accountManager.cpp b/accountManager.cpp index f8555b1..72fdde9 100644 --- a/accountManager.cpp +++ b/accountManager.cpp @@ -195,16 +195,3 @@ int AccountManager::setLastAccountNumber(size_t number) return 0; } -bool AccountManager::isDirExist(const std::string& path) -{ - struct stat info; - if (stat(path.c_str(), &info) != 0) { - return false; - } - return (info.st_mode & S_IFDIR) != 0; -} - -bool AccountManager::createDir(std::string path, std::string atLinux) -{ - return system(std::string("mkdir " + atLinux + "'" + path +"'").c_str()); // -p if is linux -} diff --git a/accountManager.h b/accountManager.h index 390b6d5..d3201b1 100644 --- a/accountManager.h +++ b/accountManager.h @@ -16,17 +16,14 @@ class AccountManager public: AccountManager(std::string pathToFile, std::string pathToAccountNumberFile); Account getNextAccount(); - - int writeDefault(std::string path); size_t getLastAccountNumber(); - int setLastAccountNumber(size_t number); - - bool isDirExist(const std::string& path); - bool createDir(std::string path, std::string atLinux = "-p "); private: std::vector accounts; std::string pathToAccountNumberFile; + int setLastAccountNumber(size_t number); + int writeDefault(std::string path); + }; #endif // ACCOUNTMANAGER_H diff --git a/pageManager.cpp b/pageManager.cpp index 8c7a920..5dd4175 100644 --- a/pageManager.cpp +++ b/pageManager.cpp @@ -1,7 +1,7 @@ #include "pageManager.h" -PageManager::PageManager(std::string sock5Proxy, std::string cookieFilePath) - : sock5Proxy(sock5Proxy), cookieFilePath(cookieFilePath) +PageManager::PageManager(std::string sock5ProxyOnlyAddress, std::string cookieFilePath) + : sock5Proxy("socks5://" + sock5ProxyOnlyAddress), cookieFilePath(cookieFilePath) { curl_global_init(CURL_GLOBAL_ALL); } diff --git a/pageManager.h b/pageManager.h index 8da2ed3..b1dad3f 100644 --- a/pageManager.h +++ b/pageManager.h @@ -22,7 +22,7 @@ struct Reply { class PageManager { public: - PageManager(std::string sock5Proxy = "socks5://127.0.0.1:9150", std::string cookieFilePath = "/tmp/S_New4_cookies"); + PageManager(std::string sock5ProxyOnlyAddress = "127.0.0.1:9150", std::string cookieFilePath = "/tmp/S_New4_cookies"); ~PageManager(); void setProxy(std::string ip, int port); diff --git a/parameterManager.cpp b/parameterManager.cpp index 760ee6d..b9b1e26 100644 --- a/parameterManager.cpp +++ b/parameterManager.cpp @@ -5,14 +5,13 @@ void setPaths(Settings &settings) //Path settings std::string executablePathTo = getexepath(); + //Entferne alles nach dem lestzten pathSymbol executablePathTo.erase(executablePathTo.find_last_of(settings.pathSymbol) + 1 , executablePathTo.length() - ( executablePathTo.find_last_of(settings.pathSymbol) + 1) ); - if(!dirExists(executablePathTo + "src" + settings.pathSymbol)) { - if(system(std::string("mkdir \"" + executablePathTo + "src" + settings.pathSymbol + "\"").c_str()) == 0) - std::cout << " => Erfolgreich Ordner 'src' erstellt." << std::endl; - else - std::cout << " => Error: Ordner '" << executablePathTo << "src' konnte nicht erstellt werden." << std::endl; - } + if(!dirExists(executablePathTo + "src" + settings.pathSymbol)) + if(createDirIsOk(executablePathTo + "src" + settings.pathSymbol)) + std::cout << " => Erfolgreich Ordner '" << executablePathTo << "src' erstellt." << std::endl; + if(dirExists(executablePathTo + "src" + settings.pathSymbol)) executablePathTo+="src" + std::string(1, settings.pathSymbol); @@ -932,7 +931,6 @@ bool fileExists (const std::string& name) { return (stat (name.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode)); } - bool nothingExists(std::string path) { struct stat buffer; @@ -950,6 +948,20 @@ bool isNumber(std::string number) return (std::to_string(atoll(number.c_str())) == number) ? true : false; } +bool createDirIsOk(std::string path) +{ +#ifdef linux + if(mkdir(path.c_str(), 0777) != 0) { +#endif +#ifdef _WIN32 + if(mkdir(path.c_str()) != 0) { +#endif + perror((" => Error: Erstellen von dem Ordner" + path + " is fehlgeschlagen").c_str()); + return false; + } else + return dirExists(path); +} + int setS5ProxytoSettings(Settings &settings, std::string Optarg) { @@ -1010,5 +1022,3 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg) return 0; } - - diff --git a/parameterManager.h b/parameterManager.h index 3a6bcb0..99c9890 100644 --- a/parameterManager.h +++ b/parameterManager.h @@ -74,6 +74,7 @@ void setPaths(Settings &settings); bool fileExists (const std::string& name); bool dirExists(std::string dir); bool nothingExists(std::string path); +bool createDirIsOk(std::string path); int unterOption_help(); diff --git a/programManager.cpp b/programManager.cpp index 03bf08f..0188515 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -216,7 +216,7 @@ int ProgramManager::defaultModus(Settings *settings) << settings->cookieFilePath + std::to_string( i ) << "'." << std::endl; return 174; } - PageManager * pm = new PageManager("socks5://" + settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i )); + PageManager * pm = new PageManager(settings->proxy_ip + ":" + std::to_string(settings->proxy_port), settings->cookieFilePath + std::to_string( i )); pm->setDebugMode(settings->debugMode); //pm->setProxy(settings->proxy_ip, settings->proxy_port); @@ -697,8 +697,7 @@ int ProgramManager::convertLink(std::string redirectLink, AccountManager * accou + "E" + std::string( (Folge < 10) ? "0" : "" ) + std::to_string( Folge ) ); std::string green = ((settings->colorless) ? "" : "\033[32m"), red = ((settings->colorless) ? "" : "\033[31m"), - orange =((settings->colorless) ? "" : "\033[33m"), - blue = ((settings->colorless) ? "" : "\033[34m"); + orange =((settings->colorless) ? "" : "\033[33m"); if(redirectLink == "" && settings->modus == Modus::DEFAULT_MODUS) { if(allLinks == "") {