forked from markus/S_New4
finish chanching paths from src to new paths
This commit is contained in:
parent
c20fd6a175
commit
e121c4b152
@ -11,8 +11,8 @@ int setPaths(Settings &settings)
|
|||||||
settings.pathSymbol = '/';
|
settings.pathSymbol = '/';
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WIN32
|
#ifdef __WIN32
|
||||||
CacheDir = std::string(getenv("AppData")) + "\\Local\\S_New4\\";
|
CacheDir = std::string(getenv("APPDATA")) + "\\Local\\S_New4\\";
|
||||||
SettingsDir = std::string( getenv("AppData") ) + "\\Roaming\\S_New4\\";
|
SettingsDir = std::string( getenv("APPDATA") ) + "\\Roaming\\S_New4\\";
|
||||||
settings.pathSymbol = '\\';
|
settings.pathSymbol = '\\';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -21,18 +21,18 @@ int setPaths(Settings &settings)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} else if(!dirExists(CacheDir)) {
|
} else if(!dirExists(CacheDir)) {
|
||||||
if(!createDirIsOk(CacheDir)) {
|
if(!makePathIsOk(CacheDir)) {
|
||||||
std::cout << " => Error: Konnte Ordner nicht erstellen: " << CacheDir << std::endl;
|
std::cout << " => Error: Konnte Ordner nicht erstellen: " << CacheDir << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
std::cout << " => Erfolgreich Ordner '" << CacheDir << "' erstellt." << std::endl;
|
std::cout << " > Erfolgreich Ordner '" << CacheDir << "' erstellt." << std::endl;
|
||||||
|
|
||||||
} if(!dirExists(SettingsDir)) {
|
} if(!dirExists(SettingsDir)) {
|
||||||
if(!createDirIsOk(SettingsDir)) {
|
if(!makePathIsOk(SettingsDir)) {
|
||||||
std::cout << " => Error: Konnte Ordner nicht erstellen: " << SettingsDir << std::endl;
|
std::cout << " => Error: Konnte Ordner nicht erstellen: " << SettingsDir << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
std::cout << " => Erfolgreich Ordner '" << SettingsDir << "' erstellt." << std::endl;
|
std::cout << " > Erfolgreich Ordner '" << SettingsDir << "' erstellt." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.cookieFilePath = CacheDir + "S_New4_cookies";
|
settings.cookieFilePath = CacheDir + "S_New4_cookies";
|
||||||
@ -78,7 +78,7 @@ int manageParameter(Settings &settings, int argc, char **argv)
|
|||||||
|
|
||||||
if(strncmp(argv[1], "--help", strlen(argv[1])) == 0) {
|
if(strncmp(argv[1], "--help", strlen(argv[1])) == 0) {
|
||||||
argv[1][0] = '\0';
|
argv[1][0] = '\0';
|
||||||
return unterOption_help(settings.programName);
|
return unterOption_help(settings);
|
||||||
|
|
||||||
} else if (strncmp(argv[1], "default", strlen(argv[1])) == 0) {
|
} else if (strncmp(argv[1], "default", strlen(argv[1])) == 0) {
|
||||||
argv[1][0] = '\0';
|
argv[1][0] = '\0';
|
||||||
@ -278,7 +278,14 @@ int unterOption_help(std::string programName)
|
|||||||
<< "\t\"default\"\tModus um Links von Serien zu bekommen." << std::endl
|
<< "\t\"default\"\tModus um Links von Serien zu bekommen." << std::endl
|
||||||
<< "\t\"search\"\tModus um Serien zu suchen." << std::endl
|
<< "\t\"search\"\tModus um Serien zu suchen." << std::endl
|
||||||
<< "\t\"info\"\t\tModus um Infos einer Serien zu bekommen." << std::endl
|
<< "\t\"info\"\t\tModus um Infos einer Serien zu bekommen." << std::endl
|
||||||
<< "\t\"clean\"\t\tModus um Cookie-Files zu löschen." << std::endl;
|
<< "\t\"clean\"\t\tModus um Cookie-Files zu löschen." << std::endl
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
std::cout << "Verzeichnisse:" << std::endl
|
||||||
|
<< "\tOrdner zum zwischenspeichern der Cookies und der AccountNummer:" << std::endl
|
||||||
|
<< "\t > '" << settings.cookieFilePath << "'" << std::endl
|
||||||
|
<< "\tOrdner zum speichern der Accounts und Default-Einstellungen:" << std::endl
|
||||||
|
<< "\t > '" << settings.defaultsFilePath << "'" << std::endl;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -937,19 +944,6 @@ bool isNumber(std::string number)
|
|||||||
return (std::to_string(atoll(number.c_str())) == number) ? true : false;
|
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)
|
int setS5ProxytoSettings(Settings &settings, std::string Optarg)
|
||||||
@ -1011,3 +1005,46 @@ int setS5ProxytoSettings(Settings &settings, std::string Optarg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool makePathIsOk(std::string path)
|
||||||
|
{
|
||||||
|
if(path == "") {
|
||||||
|
std::cout << " => Error: Üngültiger Pfad: ''." << std::endl;
|
||||||
|
return false;
|
||||||
|
} else if (path[path.length()-1] == '/' || path[path.length()-1] == '\\')
|
||||||
|
path.pop_back();
|
||||||
|
|
||||||
|
if(createDirIsOk(path))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
else if(errno == ENOENT) {
|
||||||
|
size_t pos = path.find_last_of("/\\");
|
||||||
|
if (pos == static_cast<size_t>(std::string::npos))
|
||||||
|
return false;
|
||||||
|
else if (!makePathIsOk( path.substr(0, pos) ))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// now, try to create again
|
||||||
|
return createDirIsOk(path);
|
||||||
|
} else if (errno == EEXIST) {
|
||||||
|
return dirExists(path);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
perror((" => Error: Erstellen von '" + path +"' ist fehlgeschlagen").c_str());
|
||||||
|
return 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 + "' ist fehlgeschlagen").c_str());
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return dirExists(path);
|
||||||
|
}
|
||||||
|
@ -72,9 +72,11 @@ int setPaths(Settings &settings);
|
|||||||
bool fileExists (const std::string& name);
|
bool fileExists (const std::string& name);
|
||||||
bool dirExists(std::string dir);
|
bool dirExists(std::string dir);
|
||||||
bool nothingExists(std::string path);
|
bool nothingExists(std::string path);
|
||||||
bool createDirIsOk(std::string path);
|
|
||||||
|
|
||||||
int unterOption_help(std::string programName);
|
bool createDirIsOk(std::string path);
|
||||||
|
bool makePathIsOk(std::string path);
|
||||||
|
|
||||||
|
int unterOption_help(Settings &settings);
|
||||||
|
|
||||||
int unterOption_default(Settings * settings, int argc, char **argv);
|
int unterOption_default(Settings * settings, int argc, char **argv);
|
||||||
void unterOption_default_help(std::string programName);
|
void unterOption_default_help(std::string programName);
|
||||||
|
Loading…
Reference in New Issue
Block a user