46 Path const& input_path)
50 if (exists(input_path))
52 if (is_directory(input_path))
54 std::stringstream err_msg;
55 err_msg <<
"attempting to open file but is a directory, of name '" << input_path.string() <<
"'";
56 throw std::runtime_error(err_msg.str());
60 in.open(input_path.c_str());
63 std::stringstream err_msg;
64 err_msg <<
"file '" << input_path.string() <<
"' hypothetically exists, but failed to open correctly";
65 throw std::runtime_error(err_msg.str());
71 std::stringstream err_msg;
72 err_msg <<
"attempting to open file which doesn't exist, of name '" << input_path.string() <<
"'";
73 throw std::runtime_error(err_msg.str());
76 catch (
const filesystem_error& ex)
78 std::stringstream err_msg;
79 err_msg <<
"boost::filesystem throw while attempting to open file '" << input_path.string() <<
"': '" << ex.what() <<
"'";
80 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:45
std::string FileToString(Path const &input_path)
Read an entire file into a string.
Definition file_utilities.hpp:91