diff options
Diffstat (limited to 'yage')
-rw-r--r-- | yage/core/iomanager.cpp | 12 | ||||
-rw-r--r-- | yage/core/iomanager.h | 13 |
2 files changed, 19 insertions, 6 deletions
diff --git a/yage/core/iomanager.cpp b/yage/core/iomanager.cpp index 3d9ea7cb..487ef8a9 100644 --- a/yage/core/iomanager.cpp +++ b/yage/core/iomanager.cpp @@ -10,11 +10,14 @@ #include <fstream> #include <stdexcept> +#include <regex> namespace yage { -bool IoManager::readFileToBuffer(const std::string &file_path, +namespace IoManager { + +bool readFileToBuffer(const std::string &file_path, std::vector<unsigned char> &buffer) { std::ifstream file(file_path, std::ios::binary); @@ -39,4 +42,11 @@ bool IoManager::readFileToBuffer(const std::string &file_path, return true; } +std::string parentDirectory(std::string file_path) +{ + return std::regex_replace(file_path, std::regex("(.*)/.*"), "$1"); +} + +} + } // namespace yage diff --git a/yage/core/iomanager.h b/yage/core/iomanager.h index 6c623adf..556cffb4 100644 --- a/yage/core/iomanager.h +++ b/yage/core/iomanager.h @@ -15,12 +15,15 @@ namespace yage { -class IoManager +namespace IoManager { -public: - static bool readFileToBuffer(const std::string &file_path, - std::vector<unsigned char> &buffer); -}; + +extern bool readFileToBuffer(const std::string &file_path, + std::vector<unsigned char> &buffer); + +extern std::string parentDirectory(std::string file_path); + +} } // namespace yage |