mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-13 06:13:06 +00:00
Merge branch 'hacky-windows-unicode-fixes' into 'master'
Hacky windows unicode fixes See merge request OpenMW/openmw!2024
This commit is contained in:
commit
2a789de8d3
2 changed files with 13 additions and 4 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,14 @@ namespace VFS
|
||||||
if (mPath.size () > 0 && mPath [prefix - 1] != '\\' && mPath [prefix - 1] != '/')
|
if (mPath.size () > 0 && mPath [prefix - 1] != '\\' && mPath [prefix - 1] != '/')
|
||||||
++prefix;
|
++prefix;
|
||||||
|
|
||||||
for (directory_iterator i (mPath); i != end; ++i)
|
for (directory_iterator i (std::filesystem::u8path(mPath)); i != end; ++i)
|
||||||
{
|
{
|
||||||
if(std::filesystem::is_directory (*i))
|
if(std::filesystem::is_directory (*i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string proper = i->path ().string ();
|
auto proper = i->path ().u8string ();
|
||||||
|
|
||||||
FileSystemArchiveFile file(proper);
|
FileSystemArchiveFile file(std::string((char*)proper.c_str(), proper.size()));
|
||||||
|
|
||||||
std::string searchable;
|
std::string searchable;
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace VFS
|
||||||
|
|
||||||
const auto inserted = mIndex.insert(std::make_pair(searchable, file));
|
const auto inserted = mIndex.insert(std::make_pair(searchable, file));
|
||||||
if (!inserted.second)
|
if (!inserted.second)
|
||||||
Log(Debug::Warning) << "Warning: found duplicate file for '" << proper << "', please check your file system for two files with the same name in different cases.";
|
Log(Debug::Warning) << "Warning: found duplicate file for '" << std::string((char*)proper.c_str(), proper.size()) << "', please check your file system for two files with the same name in different cases.";
|
||||||
else
|
else
|
||||||
out[inserted.first->first] = &inserted.first->second;
|
out[inserted.first->first] = &inserted.first->second;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue