#include "file.h"

string load_file_to_string(string filepath) {
  std::ifstream in_file(filepath);
  string str;

  if (in_file.is_open()) {
    in_file.seekg(0, std::ios::end);
    str.reserve(in_file.tellg());
    in_file.seekg(0, std::ios::beg);

    str.assign((std::istreambuf_iterator<char>(in_file)),
                std::istreambuf_iterator<char>());
    in_file.close();
  } else {
    return "";
  }

  if (in_file.bad() || in_file.fail()) {
    in_file.close();
    return "";
  }

  in_file.close();

  return str;
}

