diff options
author | Oleg Morozenkov <reo7sp@users.noreply.github.com> | 2017-01-26 00:32:22 +0300 |
---|---|---|
committer | Oleg Morozenkov <reo7sp@users.noreply.github.com> | 2017-01-26 00:32:22 +0300 |
commit | 85e0e991973594fb458410876a1cc09c5971b918 (patch) | |
tree | 08186c9e9f58cdb617b9b63d583f535b1c884b72 /src/tools | |
parent | 3549754e53f79e9ba0b00fb0bbded5d56a14ef51 (diff) |
Helper method for loading files. Photo upload example. Fixes #24
Diffstat (limited to 'src/tools')
-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; +} + +}; |