48 Path
const& input_path)
52 if (exists(input_path))
54 if (is_directory(input_path))
56 std::stringstream err_msg;
57 err_msg <<
"attempting to open file but is a directory, of name '" << input_path.string() <<
"'";
58 throw std::runtime_error(err_msg.str());
62 in.open(input_path.c_str());
65 std::stringstream err_msg;
66 err_msg <<
"file '" << input_path.string() <<
"' hypothetically exists, but failed to open correctly";
67 throw std::runtime_error(err_msg.str());
73 std::stringstream err_msg;
74 err_msg <<
"attempting to open file which doesn't exist, of name '" << input_path.string() <<
"'";
75 throw std::runtime_error(err_msg.str());
78 catch (
const filesystem_error& ex)
80 std::stringstream err_msg;
81 err_msg <<
"boost::filesystem throw while attempting to open file '" << input_path.string() <<
"': '" << ex.what() <<
"'";
82 throw std::runtime_error(err_msg.str());
void OpenInFileThrowIfFail(ifstream &in, Path const &input_path)
Try to open a file, and throw if it doesn't exist, or is a directory.
Definition file_utilities.hpp:47
std::string FileToString(Path const &input_path)
Read an entire file into a string.
Definition file_utilities.hpp:93