diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index 136743a..a71e88c 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -2015,3 +2015,19 @@ void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) { void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) { return FSNodeHistory(std::to_string(_path), _historyCount); } + +std::string etk::FSNodeReadAllData(const std::string& _path) { + std::string output; + etk::FSNode node(_path); + if (node.fileOpenRead() == false) { + TK_ERROR("can not open file : '" << node << "'"); + return ""; + } + std::string tmp; + while (node.fileGets(tmp) == true) { + output += tmp; + } + output += tmp; + node.fileClose(); + return output; +} diff --git a/etk/os/FSNode.h b/etk/os/FSNode.h index b048eab..51cf298 100644 --- a/etk/os/FSNode.h +++ b/etk/os/FSNode.h @@ -673,6 +673,12 @@ namespace etk { */ void FSNodeHistory(const std::string& _path, int32_t _historyCount); void FSNodeHistory(const std::u32string& _path, int32_t _historyCount); + /** + * @brief Read all the data from a file + * @param[in] _path Folder/File/Pipe path of the node + * @return all the data of the file in a string + */ + std::string FSNodeReadAllData(const std::string& _path); }; #endif