[DEV] Add API to create list ob search path for ewol font

This commit is contained in:
Edouard DUPIN 2015-09-25 21:12:02 +02:00
parent ce986790d0
commit f23c54e1a4
3 changed files with 47 additions and 1 deletions

View File

@ -68,7 +68,7 @@
#endif
#ifdef DEBUG
#define DEFAULT_LOG_LEVEL etk::log::logLevelDebug
#define DEFAULT_LOG_LEVEL etk::log::logLevelInfo
#define DEFAULT_LOG_COLOR true
#define DEFAULT_LOG_LINE true
#define DEFAULT_LOG_THREAD_ID true

View File

@ -2328,4 +2328,35 @@ std::string etk::FSNodeGetRealName(const std::string& _path) {
return node.getFileSystemName();
}
std::vector<std::string> etk::FSNodeExplodeMultiplePath(const std::string& _path) {
std::vector<std::string> out;
std::string libSearch = "";
std::string newName = _path;
if ( _path.size() > 0
&& _path[0] == '{') {
// special case: Reference of searching in subLib folder ==> library use-case
size_t firstPos = _path.find('}');
if (firstPos != std::string::npos) {
// we find a theme name : We extracted it :
libSearch = std::string(_path, 1, firstPos-1);
newName = std::string(_path, firstPos+1);
} else {
TK_ERROR("start a path name with '{' without '}' : " << _path);
// remove in case the {
newName = std::string(_path, 1);
}
}
if (libSearch.size() != 0) {
if (libSearch[0] != '@') {
out.push_back(newName);
out.push_back(std::string("{@") + libSearch + "}" + newName);
return out;
}
out.push_back(std::string("{") + libSearch + "}" + newName);
return out;
}
out.push_back(newName);
return out;
}

View File

@ -875,6 +875,21 @@ namespace etk {
* @return return real file name "/aaa/bbb/ccc/xxx"
*/
std::string FSNodeGetRealName(const std::string& _path);
/**
* @brief Get all the Path contain in the specidy path:
* @param[in] _path Generic path to parse ...
* @return The list of path found
* @example[start]
* auto out = etk::FSNodeExplodeMultiplePath("{ewol}DATA:font");
* // out contain: {"DATA:font", "{@ewol}DATA:font"}
* @example[stop]
* @example[start]
* auto out = etk::FSNodeExplodeMultiplePath("{@ewol}DATA:font");
* // out contain: {"{@ewol}DATA:font"}
* @example[stop]
*/
std::vector<std::string> FSNodeExplodeMultiplePath(const std::string& _path);
};
#endif