fix erplaceing errno

This commit is contained in:
Markus 2019-09-04 10:51:46 +02:00
parent 98d8adfdfe
commit 66b3d9b08f
2 changed files with 9 additions and 16 deletions

View File

@ -8,21 +8,26 @@ int setPaths(Settings &settings)
#ifdef linux
CacheDir = std::string(getenv("HOME")) + "/.cache/S_New4/";
SettingsDir = std::string( getenv("HOME") ) + "/.config/S_New4/";
settings.pathSymbol = '/';
#endif
#ifdef __WIN32
CacheDir = std::string(getenv("AppData")) + "\\Local\\S_New4\\";
SettingsDir = std::string( getenv("AppData") ) + "\\Roaming\\S_New4\\";
settings.pathSymbol = '\\';
#endif

if(!dirExists(CacheDir)) {
if(CacheDir == "" || SettingsDir == "") {
std::cout << " => Error: PfadVariablen sind nicht gesetzt." << std::endl;
return -1;

} else if(!dirExists(CacheDir)) {
if(!createDirIsOk(CacheDir)) {
std::cout << " => Error: Konnte Ordner nicht erstellen: " << CacheDir << std::endl;
return -1;
} else
std::cout << " => Erfolgreich Ordner '" << CacheDir << "' erstellt." << std::endl;

}
if(!dirExists(SettingsDir)) {
} if(!dirExists(SettingsDir)) {
if(!createDirIsOk(SettingsDir)) {
std::cout << " => Error: Konnte Ordner nicht erstellen: " << SettingsDir << std::endl;
return -1;
@ -43,7 +48,6 @@ int setPaths(Settings &settings)
int manageParameter(Settings &settings, int argc, char **argv)
{
//Path settings
setPathSymbol(settings);
if(setPaths(settings) != 0)
return -1;
if(loadDefaulOptions(settings) != 0)
@ -873,7 +877,7 @@ void unterOption_clean(Settings * settings, int argc, char **argv)

for (unsigned i = 0; i < UINT_MAX && fileExists(settings->cookieFilePath + std::to_string(i)); i++) {
if(remove( (settings->cookieFilePath + std::to_string(i)).c_str() ) != 0) {
std::cout << " => Error: Das löschen von " << settings->cookieFilePath + std::to_string(i) << " ist fehlgeschlagen: " << errno << std::endl;
perror((" => Error: Das löschen von " + settings->cookieFilePath + std::to_string(i) + " ist fehlgeschlagen: ").c_str());
return;
} else {
count++;
@ -934,16 +938,6 @@ std::string getexepath()
#endif
}

void setPathSymbol(Settings &settings)
{
#ifdef linux
settings.pathSymbol = '/';
#endif
#ifdef _WIN32
settings.pathSymbol = '\\';
#endif
}

bool fileExists (const std::string& name) {
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0 && S_ISREG(buffer.st_mode));

View File

@ -69,7 +69,6 @@ bool isNumber(std::string number);
std::string getProgramName();
std::string getexepath();

void setPathSymbol(Settings &settings);
int setPaths(Settings &settings);

bool fileExists (const std::string& name);