diff options
Diffstat (limited to 'src/tools/FileTools.cpp')
-rw-r--r-- | src/tools/FileTools.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/FileTools.cpp b/src/tools/FileTools.cpp new file mode 100644 index 0000000..1522a9d --- /dev/null +++ b/src/tools/FileTools.cpp @@ -0,0 +1,25 @@ +// +// Created by Oleg on 25.01.17. +// + +#include "tgbot/tools/FileTools.h" + +#include <fstream> +#include <sstream> + +using namespace std; + +namespace FileTools { + +std::string read(const std::string& filePath) { + ifstream in(filePath, ios::in | ios::binary); + if (in) { + ostringstream contents; + contents << in.rdbuf(); + in.close(); + return contents.str(); + } + throw errno; +} + +}; |