[DEV] add simple file reader
This commit is contained in:
parent
7c41031ee0
commit
7b04c193ca
@ -2015,3 +2015,19 @@ void etk::FSNodeHistory(const std::string& _path, int32_t _historyCount) {
|
|||||||
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
void etk::FSNodeHistory(const std::u32string& _path, int32_t _historyCount) {
|
||||||
return FSNodeHistory(std::to_string(_path), _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;
|
||||||
|
}
|
||||||
|
@ -673,6 +673,12 @@ namespace etk {
|
|||||||
*/
|
*/
|
||||||
void FSNodeHistory(const std::string& _path, int32_t _historyCount);
|
void FSNodeHistory(const std::string& _path, int32_t _historyCount);
|
||||||
void FSNodeHistory(const std::u32string& _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
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user