diff --git a/etk/path/fileSystem.cpp b/etk/path/fileSystem.cpp index d42d719..8fcd155 100644 --- a/etk/path/fileSystem.cpp +++ b/etk/path/fileSystem.cpp @@ -607,3 +607,15 @@ etk::Vector etk::path::listRecursive(const etk::Path& _path, uint32_t return out; } + +etk::Path etk::path::findInParent(const etk::Path& _path, const etk::String& _fileName) { + etk::Path base = _path; + while (base.getAbsolute() != "/") { + etk::Path tmp = base / _fileName; + if (etk::path::isFile(tmp) == true) { + return tmp; + } + base.parent(); + } + return base; +} \ No newline at end of file diff --git a/etk/path/fileSystem.hpp b/etk/path/fileSystem.hpp index 831d32c..45fb2cd 100644 --- a/etk/path/fileSystem.hpp +++ b/etk/path/fileSystem.hpp @@ -286,10 +286,17 @@ namespace etk { etk::Vector list(const etk::Path& _path, uint32_t _flags=etk::path::LIST_ALL); /** * @brief List the content of a specific path (recursively). - * @param[in] Path to parse. + * @param[in] _path Path to parse. * @return the full list of path in the _path. */ etk::Vector listRecursive(const etk::Path& _path, uint32_t _flags=etk::path::LIST_ALL); + /** + * @brief Find a filename in the parents directory of the path + * @param[in] _path Path to parse. + * @param[in] _fileName Name of the file we need to find + * @return the path of the file found + */ + etk::Path findInParent(const etk::Path& _path, const etk::String& _fileName); } }