summaryrefslogtreecommitdiff
path: root/src/tools/FileTools.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/FileTools.cpp')
-rw-r--r--src/tools/FileTools.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/tools/FileTools.cpp b/src/tools/FileTools.cpp
index 279f152..f18b85e 100644
--- a/src/tools/FileTools.cpp
+++ b/src/tools/FileTools.cpp
@@ -13,23 +13,18 @@ namespace FileTools {
string read(const string& filePath) {
ifstream in(filePath, ios::in | ios::binary);
- if (!in) {
- throw system_error(errno, system_category());
- }
+ in.exceptions(ifstream::failbit | ifstream::badbit);
ostringstream contents;
contents << in.rdbuf();
in.close();
return contents.str();
}
-bool write(const string& content, const string& filePath) {
+void write(const string& content, const string& filePath) {
ofstream out(filePath, ios::out | ios::binary);
- if (!out) {
- return false;
- }
+ out.exceptions(ofstream::failbit | ofstream::badbit);
out << content;
out.close();
- return true;
}
};