chore: De-duplicate code for parse(std::filesystem::path)

This commit is contained in:
Lukáš Hrázký 2022-09-08 16:52:46 +02:00
parent bf9c9d620d
commit 021d84623c

View File

@ -2516,13 +2516,7 @@ template<typename Comment = TOML11_DEFAULT_COMMENT_STRATEGY,
template<typename ...> class Array = std::vector> template<typename ...> class Array = std::vector>
basic_value<Comment, Table, Array> parse(const std::filesystem::path& fpath) basic_value<Comment, Table, Array> parse(const std::filesystem::path& fpath)
{ {
std::ifstream ifs(fpath, std::ios_base::binary); return parse<Comment, Table, Array>(fpath.string());
if(!ifs.good())
{
throw std::runtime_error("toml::parse: file open error -> " +
fpath.string());
}
return parse<Comment, Table, Array>(ifs, fpath.string());
} }
#endif // TOML11_HAS_STD_FILESYSTEM #endif // TOML11_HAS_STD_FILESYSTEM