fixes + chanche defaults + switch automatily path symbol

This commit is contained in:
Your Name 2021-01-12 20:41:58 +01:00
parent f3a4878d2a
commit 763c500c87
3 changed files with 14 additions and 3 deletions

View File

@ -9,11 +9,13 @@ int setPaths(Settings &settings)
CacheDir = std::string(getenv("HOME")) + "/.cache/S_New4/"; CacheDir = std::string(getenv("HOME")) + "/.cache/S_New4/";
SettingsDir = std::string( getenv("HOME") ) + "/.config/S_New4/"; SettingsDir = std::string( getenv("HOME") ) + "/.config/S_New4/";
settings.pathSymbol = '/'; settings.pathSymbol = '/';
settings.wrongPathSymbol = '\\';
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
CacheDir = std::string(getenv("LOCALAPPDATA")) + "\\S_New4\\"; // C:\Users\{username}\AppData\Local CacheDir = std::string(getenv("LOCALAPPDATA")) + "\\S_New4\\"; // C:\Users\{username}\AppData\Local
SettingsDir = std::string( getenv("APPDATA") ) + "\\S_New4\\"; // C:\Users\{username}\AppData\Roaming SettingsDir = std::string( getenv("APPDATA") ) + "\\S_New4\\"; // C:\Users\{username}\AppData\Roaming
settings.pathSymbol = '\\'; settings.pathSymbol = '\\';
settings.wrongPathSymbol = '/';
#endif #endif


if(CacheDir == "" || SettingsDir == "") { if(CacheDir == "" || SettingsDir == "") {
@ -196,7 +198,7 @@ int loadDefaulOptions(Settings &settings)
ofs << "#" << std::endl << "# -> Einstellungen für default Modus:" << std::endl << "#" << std::endl << std::endl; ofs << "#" << std::endl << "# -> Einstellungen für default Modus:" << std::endl << "#" << std::endl << std::endl;


ofs << "# -> Standart Wert für Parameter: -g, --genaue-hoster:" << std::endl; ofs << "# -> Standart Wert für Parameter: -g, --genaue-hoster:" << std::endl;
ofs << "default_GenaueHoster=Vivo,GoUnlimited" << std::endl << std::endl; ofs << "default_GenaueHoster=UpStream,Vidoza,Vivo,GoUnlimited" << std::endl << std::endl;


ofs << "# -> Standart Wert für Parameter: -l, --languages:" << std::endl; ofs << "# -> Standart Wert für Parameter: -l, --languages:" << std::endl;
ofs << "#default_Sprachen=GerDub,GerSub,Eng" << std::endl << std::endl; ofs << "#default_Sprachen=GerDub,GerSub,Eng" << std::endl << std::endl;
@ -208,7 +210,7 @@ int loadDefaulOptions(Settings &settings)
ofs << "#default_CheckMaxDirs=20" << std::endl << std::endl; ofs << "#default_CheckMaxDirs=20" << std::endl << std::endl;


ofs << "# -> Standart Wert für Parameter: -t, --threads:" << std::endl; ofs << "# -> Standart Wert für Parameter: -t, --threads:" << std::endl;
ofs << "#default_maxThreads=0" << std::endl << std::endl; ofs << "default_maxThreads=3" << std::endl << std::endl;


ofs << "#" << std::endl << "# -> Einstellungen für search Modus:" << std::endl << "#" << std::endl << std::endl; ofs << "#" << std::endl << "# -> Einstellungen für search Modus:" << std::endl << "#" << std::endl << std::endl;



View File

@ -27,7 +27,7 @@


#define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files=" #define UpdaterCloudUrlWithPath "https://cloud.obermui.de/s/tXz7SWdaPJ7TacZ/download?path=%2F&files="
#define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files=" #define SecondUpdaterCloudUrlWithPath "https://snew4.obermui.de/download?path=%2F&files="
#define VERSION "4.3.4" #define VERSION "4.3.5"






@ -118,6 +118,8 @@ struct Settings {
default_maxDirs = 20, default_maxDirs = 20,
updateWarningDays = 10; updateWarningDays = 10;
char pathSymbol = '/'; char pathSymbol = '/';
char wrongPathSymbol = '\\';

unsigned maxThreads = 0; unsigned maxThreads = 0;


}; };

View File

@ -350,9 +350,16 @@ int ProgramManager::defaultModus(Settings *settings)
//Wenn kein Name mit -n Angegeben wurde: //Wenn kein Name mit -n Angegeben wurde:
if(settings->name == "") { if(settings->name == "") {
if(settings->default_checkPath != "") { if(settings->default_checkPath != "") {
if(settings->default_checkPath.find(settings->pathSymbol) == std::string::npos && settings->default_checkPath.find(settings->wrongPathSymbol) != std::string::npos ) {
char t = settings->wrongPathSymbol;
settings->wrongPathSymbol = settings->pathSymbol;
settings->pathSymbol = t;
}

if(settings->default_checkPath[settings->default_checkPath.length()-1] == settings->pathSymbol) if(settings->default_checkPath[settings->default_checkPath.length()-1] == settings->pathSymbol)
settings->default_checkPath.pop_back(); settings->default_checkPath.pop_back();
size_t pos = settings->default_checkPath.find_last_of(std::string(1, settings->pathSymbol)); size_t pos = settings->default_checkPath.find_last_of(std::string(1, settings->pathSymbol));

if( pos != std::string::npos) { if( pos != std::string::npos) {
settings->name = settings->default_checkPath.substr(pos + 1); settings->name = settings->default_checkPath.substr(pos + 1);
if(settings->debugMode) if(settings->debugMode)