summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorOleg Morozenkov <m@oleg.rocks>2018-07-26 00:03:15 +0300
committerOleg Morozenkov <m@oleg.rocks>2018-07-26 00:03:15 +0300
commit2234450b81e3451a3e14686e80e13e66cf6d2a4a (patch)
tree1eeda88af36566425621c34092df9e63b5749037 /src/tools
parent399eb75d2af1e641fd80b25d1729ef250a66314a (diff)
Test on old ubuntu
Diffstat (limited to 'src/tools')
-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;
}
};