aboutsummaryrefslogtreecommitdiff
path: root/include/dchat/FileUtil.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/dchat/FileUtil.hpp')
-rw-r--r--include/dchat/FileUtil.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/dchat/FileUtil.hpp b/include/dchat/FileUtil.hpp
new file mode 100644
index 0000000..097b607
--- /dev/null
+++ b/include/dchat/FileUtil.hpp
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "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);
+}