From 6cf1b62cebdb6fb0bea821a8b078033bccada935 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 12 Dec 2016 21:54:40 +0100 Subject: [PATCH] [DEV] add generic get file size --- etk/os/FSNode.cpp | 13 +++++++++++++ etk/os/FSNode.hpp | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/etk/os/FSNode.cpp b/etk/os/FSNode.cpp index fa4871e..8630a6f 100644 --- a/etk/os/FSNode.cpp +++ b/etk/os/FSNode.cpp @@ -2412,6 +2412,19 @@ std::string etk::theme::getNameDefault(const std::string& _refName) { * Simple direct wrapper on the FileSystem node access : * * -------------------------------------------------------------------------- */ +uint64_t etk::FSNodeGetSize(const std::string& _path) { + etk::FSNode tmpNode(_path); + if (false==tmpNode.exist()) { + return 0; + } + return tmpNode.fileSize(); +} +#if __CPP_VERSION__ >= 2011 + uint64_t etk::FSNodeGetSize(const std::u32string& _path) { + return FSNodeGetSize(etk::to_string(_path)); + } +#endif + bool etk::FSNodeRemove(const std::string& _path) { etk::FSNode tmpNode(_path); if (false==tmpNode.exist()) { diff --git a/etk/os/FSNode.hpp b/etk/os/FSNode.hpp index ff1d289..83602ff 100644 --- a/etk/os/FSNode.hpp +++ b/etk/os/FSNode.hpp @@ -735,6 +735,15 @@ namespace etk { std::vector listU(); #endif }; + /** + * @brief Get the size of a specific file + * @param[in] _path Folder/File/Pipe path of the node + * @return size of the file + */ + uint64_t FSNodeGetSize(const std::string& _path); + #if __CPP_VERSION__ >= 2011 + uint64_t FSNodeGetSize(const std::u32string& _path); + #endif /** * @brief Simple access for : Remove folder and subFolder, files pipes ...