2022-04-14 20:12:59 +00:00
|
|
|
#include "openfile.hpp"
|
2022-07-02 22:02:29 +00:00
|
|
|
#include "conversion.hpp"
|
2022-04-14 20:12:59 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace Files
|
|
|
|
{
|
2022-06-19 11:28:33 +00:00
|
|
|
std::unique_ptr<std::ifstream> openBinaryInputFileStream(const std::filesystem::path& path)
|
2022-04-14 20:12:59 +00:00
|
|
|
{
|
|
|
|
auto stream = std::make_unique<std::ifstream>(path, std::ios::binary);
|
|
|
|
if (!stream->is_open())
|
2023-01-29 20:56:59 +00:00
|
|
|
throw std::system_error(errno, std::generic_category(),
|
|
|
|
"Failed to open '" + Files::pathToUnicodeString(path) + "' for reading");
|
2022-04-14 20:12:59 +00:00
|
|
|
stream->exceptions(std::ios::badbit);
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
}
|