summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/FileTools.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/tools/FileTools.cpp b/src/tools/FileTools.cpp
index 14c322c..105d80f 100644
--- a/src/tools/FileTools.cpp
+++ b/src/tools/FileTools.cpp
@@ -11,25 +11,25 @@ using namespace std;
namespace FileTools {
-std::string read(const std::string& filePath) {
+string read(const string& filePath) {
ifstream in(filePath, ios::in | ios::binary);
- if (in) {
- ostringstream contents;
- contents << in.rdbuf();
- in.close();
- return contents.str();
+ if (!in) {
+ throw system_error(errno, system_category());
}
- throw errno;
+ ostringstream contents;
+ contents << in.rdbuf();
+ in.close();
+ return contents.str();
}
-bool write(const std::string& content, const std::string& filePath) {
+bool write(const string& content, const string& filePath) {
ofstream out(filePath, ios::out | ios::binary);
- if (out) {
- out << content;
- out.close();
- return true;
+ if (!out) {
+ return false;
}
- return false;
+ out << content;
+ out.close();
+ return true;
}
};