diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2018-03-10 15:17:40 +0300 |
---|---|---|
committer | Oleg Morozenkov <m@oleg.rocks> | 2018-03-10 15:17:40 +0300 |
commit | f26e8402cf886fbb49ef7047024d40b3fc2bfe17 (patch) | |
tree | 31e38fa9a2ccefae50bc558e25bad4a98a87c8bf | |
parent | 6f8c497df3c45fac58d0da0af8ca1e98f6bf2ed3 (diff) |
Fixes #55
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | include/tgbot/tgbot.h | 2 | ||||
-rw-r--r-- | src/tools/FileTools.cpp | 26 |
3 files changed, 16 insertions, 15 deletions
@@ -8,4 +8,5 @@ Thumbs.db doc/ *.cbp *.a -test/TgBot_test
\ No newline at end of file +test/TgBot_test +.vscode/
\ No newline at end of file diff --git a/include/tgbot/tgbot.h b/include/tgbot/tgbot.h index b9d93c3..a6efd62 100644 --- a/include/tgbot/tgbot.h +++ b/include/tgbot/tgbot.h @@ -72,7 +72,7 @@ * @defgroup tools * * @mainpage - * [Go to GitHub](https://github.com/reo7sp) + * [Go to GitHub](https://github.com/reo7sp/tgbot-cpp) * * @section lib_compile Library compilation * 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; } }; |