[DEV] Change FSNode interface add {libName} to provide an API to library to have personel data
This commit is contained in:
parent
4393fdf060
commit
11fb148e96
@ -40,8 +40,8 @@ extern "C" {
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "FSNode"
|
#define __class__ "FSNode"
|
||||||
|
|
||||||
#define TK_DBG_MODE TK_VERBOSE
|
//#define TK_DBG_MODE TK_VERBOSE
|
||||||
//#define TK_DBG_MODE TK_DEBUG
|
#define TK_DBG_MODE TK_DEBUG
|
||||||
|
|
||||||
std::string etk::simplifyPath(std::string _input) {
|
std::string etk::simplifyPath(std::string _input) {
|
||||||
// step 1 : for windows change \ in /:
|
// step 1 : for windows change \ in /:
|
||||||
@ -589,7 +589,7 @@ void etk::FSNode::sortElementList(std::vector<etk::FSNode *>& _list) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void etk::FSNode::privateSetName(const std::string& _newName) {
|
void etk::FSNode::privateSetName(std::string _newName) {
|
||||||
if( NULL != m_PointerFile
|
if( NULL != m_PointerFile
|
||||||
#ifdef HAVE_ZIP_DATA
|
#ifdef HAVE_ZIP_DATA
|
||||||
|| NULL != m_zipContent
|
|| NULL != m_zipContent
|
||||||
@ -601,6 +601,22 @@ void etk::FSNode::privateSetName(const std::string& _newName) {
|
|||||||
// set right at NULL ...
|
// set right at NULL ...
|
||||||
m_rights = 0;
|
m_rights = 0;
|
||||||
|
|
||||||
|
m_libSearch = "";
|
||||||
|
if ( _newName.size() > 0
|
||||||
|
&& _newName[0] == '{') {
|
||||||
|
// special case: Reference of searching in subLib folder ==> library use-case
|
||||||
|
size_t firstPos = _newName.find('}');
|
||||||
|
if (firstPos != std::string::npos) {
|
||||||
|
// we find a theme name : We extracted it :
|
||||||
|
m_libSearch = std::string(_newName, 1, firstPos-1);
|
||||||
|
_newName = std::string(_newName, firstPos+1);
|
||||||
|
} else {
|
||||||
|
TK_ERROR("start a path name with '{' without '}' : " << _newName);
|
||||||
|
// remove in case the {
|
||||||
|
_newName = std::string(_newName, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ZIP_DATA
|
#ifdef HAVE_ZIP_DATA
|
||||||
m_zipContent = NULL;
|
m_zipContent = NULL;
|
||||||
m_zipReadingOffset = 0;
|
m_zipReadingOffset = 0;
|
||||||
@ -786,6 +802,11 @@ bool directCheckFile(std::string _tmpFileNameDirect, bool _checkInAPKIfNeeded =
|
|||||||
#endif
|
#endif
|
||||||
// Now we generate the real FS path:
|
// Now we generate the real FS path:
|
||||||
void etk::FSNode::generateFileSystemPath() {
|
void etk::FSNode::generateFileSystemPath() {
|
||||||
|
bool forceLibFolder(false);
|
||||||
|
if ( m_libSearch.size() > 0
|
||||||
|
&& m_libSearch[0] == '@') {
|
||||||
|
forceLibFolder = true;
|
||||||
|
}
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
default:
|
default:
|
||||||
case etk::FSN_TYPE_UNKNOW:
|
case etk::FSN_TYPE_UNKNOW:
|
||||||
@ -811,7 +832,23 @@ void etk::FSNode::generateFileSystemPath() {
|
|||||||
m_systemFileName = baseFolderHome;
|
m_systemFileName = baseFolderHome;
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_DATA:
|
case etk::FSN_TYPE_DATA:
|
||||||
m_systemFileName = baseFolderData;
|
{
|
||||||
|
TK_DBG_MODE("DATA lib : \"" << m_libSearch << "\" => \"" << m_userFileName << "\" forceLib = " << forceLibFolder);
|
||||||
|
// search the correct folder:
|
||||||
|
if (forceLibFolder == false) {
|
||||||
|
// check in the application folder.
|
||||||
|
TK_DBG_MODE("DATA Search in application data:");
|
||||||
|
m_systemFileName = simplifyPath(baseFolderData + "/" + m_userFileName);
|
||||||
|
if (directCheckFile(m_systemFileName) == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_libSearch.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_systemFileName = simplifyPath(baseFolderData + "/../" + m_libSearch + "/" + m_userFileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_USER_DATA:
|
case etk::FSN_TYPE_USER_DATA:
|
||||||
m_systemFileName = baseFolderDataUser;
|
m_systemFileName = baseFolderDataUser;
|
||||||
@ -835,10 +872,11 @@ void etk::FSNode::generateFileSystemPath() {
|
|||||||
themeName = etk::theme::getName(themeName);
|
themeName = etk::theme::getName(themeName);
|
||||||
std::string themeNameDefault = etk::theme::getNameDefault(themeName);
|
std::string themeNameDefault = etk::theme::getNameDefault(themeName);
|
||||||
TK_DBG_MODE(" ==> theme Folder \"" << themeName << "\"");
|
TK_DBG_MODE(" ==> theme Folder \"" << themeName << "\"");
|
||||||
// search the corect folder :
|
// search the correct folder :
|
||||||
if (themeName == "") {
|
if (themeName == "") {
|
||||||
TK_WARNING("no theme name detected : set it to '" << themeNameDefault << "'");
|
TK_WARNING("no theme name detected : set it to '" << themeNameDefault << "'");
|
||||||
} else if (themeName != themeNameDefault) {
|
} else if (themeName != themeNameDefault) {
|
||||||
|
if (forceLibFolder == false) {
|
||||||
// Selected theme :
|
// Selected theme :
|
||||||
// check in the user data :
|
// check in the user data :
|
||||||
m_systemFileName = simplifyPath(baseFolderDataUser + "theme/" + themeName + "/" + basicName);
|
m_systemFileName = simplifyPath(baseFolderDataUser + "theme/" + themeName + "/" + basicName);
|
||||||
@ -852,7 +890,23 @@ void etk::FSNode::generateFileSystemPath() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_libSearch.size() > 0) {
|
||||||
|
// Selected theme :
|
||||||
|
// check in the user data :
|
||||||
|
m_systemFileName = simplifyPath(baseFolderDataUser + "/../" + m_libSearch + "/theme/" + themeName + "/" + basicName);
|
||||||
|
if (directCheckFile(m_systemFileName) == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// check in the Appl data :
|
||||||
|
m_systemFileName = simplifyPath(baseFolderData + "/../" + m_libSearch + "/theme/" + themeName + "/" + basicName);
|
||||||
|
if (directCheckFile(m_systemFileName, true) == true) {
|
||||||
|
m_type = etk::FSN_TYPE_THEME_DATA;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// default theme :
|
// default theme :
|
||||||
|
if (forceLibFolder == false) {
|
||||||
// check in the user data :
|
// check in the user data :
|
||||||
m_systemFileName = simplifyPath(baseFolderDataUser + "theme/" + themeNameDefault + "/" + basicName);
|
m_systemFileName = simplifyPath(baseFolderDataUser + "theme/" + themeNameDefault + "/" + basicName);
|
||||||
if (true==directCheckFile(m_systemFileName)) {
|
if (true==directCheckFile(m_systemFileName)) {
|
||||||
@ -864,6 +918,22 @@ void etk::FSNode::generateFileSystemPath() {
|
|||||||
m_type = etk::FSN_TYPE_THEME_DATA;
|
m_type = etk::FSN_TYPE_THEME_DATA;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_libSearch.size() == 0) {
|
||||||
|
m_type = etk::FSN_TYPE_UNKNOW;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check in the user data :
|
||||||
|
m_systemFileName = simplifyPath(baseFolderDataUser + "/../" + m_libSearch + "/theme/" + themeNameDefault + "/" + basicName);
|
||||||
|
if (true==directCheckFile(m_systemFileName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// check in the Appl data : In every case we return this one ...
|
||||||
|
m_systemFileName = simplifyPath(baseFolderData + "/../" + m_libSearch + "/theme/" + themeNameDefault + "/" + basicName);
|
||||||
|
if (true==directCheckFile(m_systemFileName, true)) {
|
||||||
|
m_type = etk::FSN_TYPE_THEME_DATA;
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_type = etk::FSN_TYPE_UNKNOW;
|
m_type = etk::FSN_TYPE_UNKNOW;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1003,33 +1073,38 @@ std::string etk::FSNode::getFileSystemName() const {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string etk::FSNode::getName() const {
|
std::string etk::FSNode::getName() const {
|
||||||
std::string output;
|
std::string output("");
|
||||||
|
if (m_libSearch.size() > 0) {
|
||||||
|
output += "{";
|
||||||
|
output += m_libSearch;
|
||||||
|
output += "}";
|
||||||
|
}
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
default:
|
default:
|
||||||
case etk::FSN_TYPE_UNKNOW:
|
case etk::FSN_TYPE_UNKNOW:
|
||||||
output = "HOME:";
|
output += "HOME:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_DIRECT:
|
case etk::FSN_TYPE_DIRECT:
|
||||||
output = "/";
|
output += "/";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_RELATIF:
|
case etk::FSN_TYPE_RELATIF:
|
||||||
output = "REL:";
|
output += "REL:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_HOME:
|
case etk::FSN_TYPE_HOME:
|
||||||
output = "~";
|
output += "~";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_DATA:
|
case etk::FSN_TYPE_DATA:
|
||||||
output = "DATA:";
|
output += "DATA:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_USER_DATA:
|
case etk::FSN_TYPE_USER_DATA:
|
||||||
output = "USERDATA:";
|
output += "USERDATA:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_CACHE:
|
case etk::FSN_TYPE_CACHE:
|
||||||
output = "CACHE:";
|
output += "CACHE:";
|
||||||
break;
|
break;
|
||||||
case etk::FSN_TYPE_THEME:
|
case etk::FSN_TYPE_THEME:
|
||||||
case etk::FSN_TYPE_THEME_DATA:
|
case etk::FSN_TYPE_THEME_DATA:
|
||||||
output = "THEME:";
|
output += "THEME:";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
output += m_userFileName;
|
output += m_userFileName;
|
||||||
|
@ -94,13 +94,11 @@ namespace etk {
|
|||||||
FSN_TYPE_CACHE,
|
FSN_TYPE_CACHE,
|
||||||
|
|
||||||
// depend on case
|
// depend on case
|
||||||
// - try on FSN_TYPE_USER_DATA/theme/themeName/xxx
|
// - try on FSN_TYPE_USER_DATA:/theme/themeName/xxx
|
||||||
// - try on FSN_TYPE_DATA/theme/themeName/xxx
|
// - try on FSN_TYPE_DATA:/theme/themeName/xxx
|
||||||
// - try on FSN_TYPE_EWOL_DATA/theme/themeName/xxx ==> later when the lib will be accessible in packages
|
|
||||||
// and jump to the default theme file
|
// and jump to the default theme file
|
||||||
// - try on FSN_TYPE_USER_DATA/theme/default/xxx
|
// - try on FSN_TYPE_USER_DATA:/theme/default/xxx
|
||||||
// - try on FSN_TYPE_DATA/theme/default/xxx
|
// - try on FSN_TYPE_DATA:/theme/default/xxx
|
||||||
// - try on FSN_TYPE_EWOL_DATA/theme/default/xxx ==> later when the lib will be accessible in packages
|
|
||||||
FSN_TYPE_THEME,
|
FSN_TYPE_THEME,
|
||||||
FSN_TYPE_THEME_DATA
|
FSN_TYPE_THEME_DATA
|
||||||
};
|
};
|
||||||
@ -109,37 +107,49 @@ namespace etk {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
note : The filename can be
|
note : The filename can be
|
||||||
Direct mode :
|
Direct mode:
|
||||||
DIRECT:/sdfsdfsdf/
|
DIRECT:/sdfsdfsdf/
|
||||||
/XX ==> for Linux / Mac / Android
|
/XX ==> for Linux / Mac / Android
|
||||||
[a-zA-Z]:/xxx ==> for Windows
|
[a-zA-Z]:/xxx ==> for Windows
|
||||||
|
|
||||||
Data mode :
|
Data mode:
|
||||||
DATA:folder/File.ccc
|
DATA:folder/File.ccc
|
||||||
|
{libName}DATA:folder/File.ccc ==> try to read in appl data and in next in "libName" lib data folder
|
||||||
|
{@libName}DATA:folder/File.ccc ==> try to read ONLY in "libName" lib data folder
|
||||||
|
|
||||||
User data mode :
|
User data mode:
|
||||||
USERDATA:folder/File.ccc
|
USERDATA:folder/File.ccc
|
||||||
|
{libName}USERDATA:folder/File.ccc
|
||||||
|
{@libName}USERDATA:folder/File.ccc
|
||||||
|
|
||||||
Cache Data :
|
Cache Data:
|
||||||
CACHE:folder/File.ccc
|
CACHE:folder/File.ccc
|
||||||
|
|
||||||
Theme data :
|
Theme data:
|
||||||
THEME:folder/file.xxx
|
THEME:folder/file.xxx
|
||||||
|
THEME:GUI:folder/file.xxx
|
||||||
|
{libName}THEME:GUI:folder/file.xxx
|
||||||
|
{@libName}THEME:GUI:folder/file.xxx
|
||||||
|
|
||||||
Get the root folder :
|
Get the root folder:
|
||||||
ROOT:
|
ROOT:
|
||||||
/
|
/
|
||||||
[a-zA-Z]: ==> create more risk ...
|
[a-zA-Z]: ==> create more risk ...
|
||||||
|
|
||||||
Get the Home folder :
|
Get the Home folder:
|
||||||
HOME:
|
HOME:
|
||||||
~
|
~
|
||||||
|
|
||||||
|
Get the relative folder:
|
||||||
|
REL:
|
||||||
|
./
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief FS node is for File system IO access This class is independent of the OS, If you acces to a file in windows, it might generate the right loke Linux (it is important to know that windows right is lighter than linux)
|
* @brief FS node is for File system IO access This class is independent of the OS, If you acces to a file in windows, it might generate the right loke Linux (it is important to know that windows right is lighter than linux)
|
||||||
*/
|
*/
|
||||||
class FSNode {
|
class FSNode {
|
||||||
private:
|
private:
|
||||||
|
std::string m_libSearch; //!< the name Of the subLib that system must church subData
|
||||||
std::string m_userFileName; //!< the name requested by the User
|
std::string m_userFileName; //!< the name requested by the User
|
||||||
std::string m_systemFileName; //!< the compleate filename for the system
|
std::string m_systemFileName; //!< the compleate filename for the system
|
||||||
enum FSNType m_type; //!< the Type of data requested by the User
|
enum FSNType m_type; //!< the Type of data requested by the User
|
||||||
@ -179,7 +189,7 @@ namespace etk {
|
|||||||
* @brief Common set name of the Node (if the user decide to change the node selection
|
* @brief Common set name of the Node (if the user decide to change the node selection
|
||||||
* @param[in] _newName Name of the Node
|
* @param[in] _newName Name of the Node
|
||||||
*/
|
*/
|
||||||
void privateSetName(const std::string& _newName);
|
void privateSetName(std::string _newName);
|
||||||
#if __CPP_VERSION__ >= 2011
|
#if __CPP_VERSION__ >= 2011
|
||||||
void privateSetName(const std::u32string& _newName);
|
void privateSetName(const std::u32string& _newName);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user