[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) {
|
if (_argc >= 1) {
|
||||||
TK_PRINT(" " << _argv[0] << " [options]");
|
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(" --etk-log-lib=name:X Set a library specific level:");
|
||||||
TK_PRINT(" name Name of the library");
|
TK_PRINT(" name Name of the library");
|
||||||
TK_PRINT(" X Log level to set [0..6]");
|
TK_PRINT(" X Log level to set [0..6]");
|
||||||
*/
|
*/
|
||||||
TK_PRINT(" -h/--help: this help");
|
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 << "'");
|
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::Vector<etk::String> elems = etk::split(_val, '/');
|
||||||
etk::initDefaultFolder(elems[elems.size()-1].c_str());
|
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:
|
On Unixes with /proc really straight and realiable way is to:
|
||||||
readlink("/proc/self/exe", buf, bufsize) (Linux)
|
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 += etk::String(binaryName.begin()+1, binaryName.end()-4);
|
||||||
baseFolderData += "/";
|
baseFolderData += "/";
|
||||||
|
|
||||||
baseFolderDataUser = binaryPath;
|
if (l_forceUSERDATA == "") {
|
||||||
baseFolderDataUser += "/user/";
|
baseFolderDataUser = binaryPath;
|
||||||
|
baseFolderDataUser += "/user/";
|
||||||
|
}
|
||||||
|
|
||||||
baseFolderCache = binaryPath;
|
baseFolderCache = binaryPath;
|
||||||
baseFolderCache += "/tmp/";
|
baseFolderCache += "/tmp/";
|
||||||
@ -616,16 +630,18 @@ void etk::initDefaultFolder(const char* _applName) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if defined(__TARGET_OS__IOs)
|
if (l_forceUSERDATA == "") {
|
||||||
baseFolderDataUser = binaryPath;
|
#if defined(__TARGET_OS__IOs)
|
||||||
baseFolderDataUser += "/../Documents/";
|
baseFolderDataUser = binaryPath;
|
||||||
baseFolderDataUser = simplifyPath(baseFolderDataUser);
|
baseFolderDataUser += "/../Documents/";
|
||||||
#else
|
baseFolderDataUser = simplifyPath(baseFolderDataUser);
|
||||||
baseFolderDataUser = baseFolderHome;
|
#else
|
||||||
baseFolderDataUser += "/.local/share/";
|
baseFolderDataUser = baseFolderHome;
|
||||||
baseFolderDataUser += binaryName;
|
baseFolderDataUser += "/.local/share/";
|
||||||
baseFolderDataUser += "/";
|
baseFolderDataUser += binaryName;
|
||||||
#endif
|
baseFolderDataUser += "/";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#if defined(__TARGET_OS__IOs)
|
#if defined(__TARGET_OS__IOs)
|
||||||
baseFolderCache = binaryPath;
|
baseFolderCache = binaryPath;
|
||||||
baseFolderCache += "/../tmp/";
|
baseFolderCache += "/../tmp/";
|
||||||
|
@ -42,6 +42,12 @@ namespace etk {
|
|||||||
* @param[in] _val First parameter.
|
* @param[in] _val First parameter.
|
||||||
*/
|
*/
|
||||||
void setArgZero(const etk::String& _val);
|
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 "///\//"
|
* @brief Simplify a path with all the complication that mean ".." or "///\//"
|
||||||
* @param[in] _input Parth to simplify
|
* @param[in] _input Parth to simplify
|
||||||
|
Loading…
x
Reference in New Issue
Block a user