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