mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +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
@ -3,11 +3,20 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
#if defined(_WIN32) || defined(__WINDOWS__)
|
||||
#include <boost/locale.hpp>
|
||||
#endif
|
||||
|
||||
namespace Files
|
||||
{
|
||||
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);
|
||||
#endif
|
||||
if (!stream->is_open())
|
||||
throw std::runtime_error("Failed to open '" + path + "' for reading: " + std::strerror(errno));
|
||||
stream->exceptions(std::ios::badbit);
|
||||
|
@ -29,14 +29,14 @@ namespace VFS
|
||||
if (mPath.size () > 0 && mPath [prefix - 1] != '\\' && mPath [prefix - 1] != '/')
|
||||
++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))
|
||||
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;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace VFS
|
||||
|
||||
const auto inserted = mIndex.insert(std::make_pair(searchable, file));
|
||||
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
|
||||
out[inserted.first->first] = &inserted.first->second;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user