summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--include/tgbot/tgbot.h2
-rw-r--r--src/tools/FileTools.cpp26
3 files changed, 16 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 01735f9..7ba713b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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;
}
};