2022-04-14 20:12:59 +00:00
|
|
|
#include "openfile.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
2022-06-15 23:28:41 +00:00
|
|
|
|
2022-04-14 20:12:59 +00:00
|
|
|
namespace Files
|
|
|
|
{
|
2022-09-09 08:13:47 +00:00
|
|
|
std::unique_ptr<boost::filesystem::ifstream> openBinaryInputFileStream(const std::string& path)
|
2022-04-14 20:12:59 +00:00
|
|
|
{
|
2022-09-09 08:13:47 +00:00
|
|
|
auto stream = std::make_unique<boost::filesystem::ifstream>(path, boost::filesystem::fstream::binary);
|
|
|
|
|
2022-04-14 20:12:59 +00:00
|
|
|
if (!stream->is_open())
|
|
|
|
throw std::runtime_error("Failed to open '" + path + "' for reading: " + std::strerror(errno));
|
2022-09-09 08:13:47 +00:00
|
|
|
stream->exceptions(boost::filesystem::fstream::badbit);
|
2022-04-14 20:12:59 +00:00
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
}
|