1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/components/files/openfile.cpp

19 lines
556 B
C++
Raw Normal View History

#include "openfile.hpp"
#include "conversion.hpp"
#include <cstring>
#include <fstream>
namespace Files
{
2022-09-22 18:26:05 +00:00
std::unique_ptr<std::ifstream> openBinaryInputFileStream(const std::filesystem::path& path)
{
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");
stream->exceptions(std::ios::badbit);
return stream;
}
}