|
|
@ -3,11 +3,20 @@
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstring>
|
|
|
|
#include <fstream>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(__WINDOWS__)
|
|
|
|
|
|
|
|
#include <boost/locale.hpp>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace Files
|
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::unique_ptr<std::ifstream> openBinaryInputFileStream(const std::string& path)
|
|
|
|
std::unique_ptr<std::ifstream> openBinaryInputFileStream(const std::string& path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#if defined(_WIN32) || defined(__WINDOWS__)
|
|
|
|
|
|
|
|
std::wstring wpath = boost::locale::conv::utf_to_utf<wchar_t>(path);
|
|
|
|
|
|
|
|
auto stream = std::make_unique<std::ifstream>(wpath, std::ios::binary);
|
|
|
|
|
|
|
|
#else
|
|
|
|
auto stream = std::make_unique<std::ifstream>(path, std::ios::binary);
|
|
|
|
auto stream = std::make_unique<std::ifstream>(path, std::ios::binary);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
if (!stream->is_open())
|
|
|
|
if (!stream->is_open())
|
|
|
|
throw std::runtime_error("Failed to open '" + path + "' for reading: " + std::strerror(errno));
|
|
|
|
throw std::runtime_error("Failed to open '" + path + "' for reading: " + std::strerror(errno));
|
|
|
|
stream->exceptions(std::ios::badbit);
|
|
|
|
stream->exceptions(std::ios::badbit);
|
|
|
|