diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-29 21:49:54 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-10-29 21:52:12 +0100 |
commit | b1296f2c97c6fdc1c6a9922dc09c951b5cafdc12 (patch) | |
tree | 0986a2e3ab45f73c1f7219deef044b3d4ca94e89 /include/FileUtil.hpp |
Initial commit
Diffstat (limited to 'include/FileUtil.hpp')
-rw-r--r-- | include/FileUtil.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp new file mode 100644 index 0000000..cb4e308 --- /dev/null +++ b/include/FileUtil.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "dchat/StringView.hpp" +#include <boost/filesystem/path.hpp> +#include <stdexcept> + +namespace dchat +{ + class FileException : public std::runtime_error + { + public: + FileException(const std::string &errMsg) : std::runtime_error(errMsg) {} + }; + + // Throws FileException on error. + // Returned value is allocated with malloc and should be free'd by caller. + StringView getFileContent(const boost::filesystem::path &filepath); + + // Throws FileException on error + void fileReplace(const boost::filesystem::path &filepath, const StringView data); +} |