Files
SDImagePreprocess/SmartCrop/readfile.h

17 lines
369 B
C++

#pragma once
#include <string>
#include <filesystem>
#include <fstream>
#include <stdexcept>
#include <sstream>
inline std::string readFile(const std::filesystem::path& path)
{
std::ifstream file(path);
if(!file.is_open())
throw std::runtime_error(std::string("could not open file ") + path.string());
std::stringstream ss;
ss<<file.rdbuf();
return ss.str();
}