C++11 library providing functionality common to all adapters.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
501 B

  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #include "slurp.hh"
  4. #include <fstream>
  5. #include <sstream>
  6. #include <stdexcept>
  7. namespace pEp
  8. {
  9. std::string slurp(const std::string& filename)
  10. {
  11. std::ifstream input(filename.c_str(), std::ios_base::binary);
  12. if(!input)
  13. {
  14. throw std::runtime_error("Cannot read file \"" + filename + "\"! ");
  15. }
  16. std::stringstream sstr;
  17. sstr << input.rdbuf();
  18. return sstr.str();
  19. }
  20. } // end of namespace pEp