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.

fileutils.cpp 602B

1234567891011121314151617181920212223242526
  1. #include <fstream>
  2. #include <string>
  3. #include "fileutils.h"
  4. #include "spdlog/spdlog.h"
  5. namespace vtk { namespace file {
  6. std::string loadFileIntoString(const std::string& fName) {
  7. std::ifstream in(fName, std::ios::in | std::ios::binary);
  8. if (in) {
  9. std::string contents;
  10. in.seekg(0, std::ios::end);
  11. contents.resize(in.tellg());
  12. in.seekg(0, std::ios::beg);
  13. in.read(&contents[0], contents.size());
  14. in.close();
  15. spdlog::get("file")->info("Loaded file: {}", fName);
  16. return contents;
  17. }
  18. spdlog::get("file")->warn("Unable to load: {}, returning empty string", fName);
  19. return "";
  20. }
  21. }}