[DEV] add --etk-base-path=name Change the default USERDATA: generic name
This commit is contained in:
parent
568cd5bbe1
commit
ba6aeee852
@ -58,13 +58,16 @@ void etk::init(int _argc, const char** _argv) {
|
||||
if (_argc >= 1) {
|
||||
TK_PRINT(" " << _argv[0] << " [options]");
|
||||
}
|
||||
TK_PRINT(" --etk-base-path=name Change the default USERDATA: generic name");
|
||||
/*
|
||||
TK_PRINT(" --etk-log-lib=name:X Set a library specific level:");
|
||||
TK_PRINT(" name Name of the library");
|
||||
TK_PRINT(" X Log level to set [0..6]");
|
||||
*/
|
||||
TK_PRINT(" -h/--help: this help");
|
||||
} else if (data.startWith("--etk")) {
|
||||
} else if (data.startWith("--etk-base-path=") == true) {
|
||||
etk::forcePathUserData(etk::String(&data[16]));
|
||||
} else if (data.startWith("--etk") == true) {
|
||||
TK_ERROR("Can not parse the argument : '" << data << "'");
|
||||
}
|
||||
}
|
||||
|
@ -407,6 +407,18 @@ void etk::setArgZero(const etk::String& _val) {
|
||||
etk::Vector<etk::String> elems = etk::split(_val, '/');
|
||||
etk::initDefaultFolder(elems[elems.size()-1].c_str());
|
||||
}
|
||||
|
||||
etk::String l_forceUSERDATA = "";
|
||||
void etk::forcePathUserData(const etk::String& _val) {
|
||||
l_forceUSERDATA = _val;
|
||||
if (l_forceUSERDATA == "") {
|
||||
TK_TODO("Reset the USERDATA: to the default path ...");
|
||||
return;
|
||||
}
|
||||
TK_INFO("Force the USERDATA: to '" << l_forceUSERDATA << "'");
|
||||
baseFolderDataUser = l_forceUSERDATA;
|
||||
}
|
||||
|
||||
/*
|
||||
On Unixes with /proc really straight and realiable way is to:
|
||||
readlink("/proc/self/exe", buf, bufsize) (Linux)
|
||||
@ -567,8 +579,10 @@ void etk::initDefaultFolder(const char* _applName) {
|
||||
baseFolderData += etk::String(binaryName.begin()+1, binaryName.end()-4);
|
||||
baseFolderData += "/";
|
||||
|
||||
baseFolderDataUser = binaryPath;
|
||||
baseFolderDataUser += "/user/";
|
||||
if (l_forceUSERDATA == "") {
|
||||
baseFolderDataUser = binaryPath;
|
||||
baseFolderDataUser += "/user/";
|
||||
}
|
||||
|
||||
baseFolderCache = binaryPath;
|
||||
baseFolderCache += "/tmp/";
|
||||
@ -616,16 +630,18 @@ void etk::initDefaultFolder(const char* _applName) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if defined(__TARGET_OS__IOs)
|
||||
baseFolderDataUser = binaryPath;
|
||||
baseFolderDataUser += "/../Documents/";
|
||||
baseFolderDataUser = simplifyPath(baseFolderDataUser);
|
||||
#else
|
||||
baseFolderDataUser = baseFolderHome;
|
||||
baseFolderDataUser += "/.local/share/";
|
||||
baseFolderDataUser += binaryName;
|
||||
baseFolderDataUser += "/";
|
||||
#endif
|
||||
if (l_forceUSERDATA == "") {
|
||||
#if defined(__TARGET_OS__IOs)
|
||||
baseFolderDataUser = binaryPath;
|
||||
baseFolderDataUser += "/../Documents/";
|
||||
baseFolderDataUser = simplifyPath(baseFolderDataUser);
|
||||
#else
|
||||
baseFolderDataUser = baseFolderHome;
|
||||
baseFolderDataUser += "/.local/share/";
|
||||
baseFolderDataUser += binaryName;
|
||||
baseFolderDataUser += "/";
|
||||
#endif
|
||||
}
|
||||
#if defined(__TARGET_OS__IOs)
|
||||
baseFolderCache = binaryPath;
|
||||
baseFolderCache += "/../tmp/";
|
||||
|
@ -42,6 +42,12 @@ namespace etk {
|
||||
* @param[in] _val First parameter.
|
||||
*/
|
||||
void setArgZero(const etk::String& _val);
|
||||
/**
|
||||
* @brief Force the "USERDATA:" to an other path (not the default path).
|
||||
* @note this is called internaly to change the path with the generic cmd line intruction ... It is dangerous to do it in runtime (after start).
|
||||
* @param[in] _val user data basic path.
|
||||
*/
|
||||
void forcePathUserData(const etk::String& _val);
|
||||
/**
|
||||
* @brief Simplify a path with all the complication that mean ".." or "///\//"
|
||||
* @param[in] _input Parth to simplify
|
||||
|
Loading…
x
Reference in New Issue
Block a user