From 6a5ad4ca43876e13f3a6fcf499c4b5b4c1335687 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 16 Jun 2022 00:28:41 +0100 Subject: [PATCH 1/3] Fix regression from https://gitlab.com/OpenMW/openmw/-/merge_requests/1776 --- components/files/openfile.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/files/openfile.cpp b/components/files/openfile.cpp index 61a177b038..54b0b28058 100644 --- a/components/files/openfile.cpp +++ b/components/files/openfile.cpp @@ -3,11 +3,20 @@ #include #include +#if defined(_WIN32) || defined(__WINDOWS__) +#include +#endif + namespace Files { std::unique_ptr openBinaryInputFileStream(const std::string& path) { +#if defined(_WIN32) || defined(__WINDOWS__) + std::wstring wpath = boost::locale::conv::utf_to_utf(path); + auto stream = std::make_unique(wpath, std::ios::binary); +#else auto stream = std::make_unique(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); From bdcac26d8c673ae9835fee26a25806860985c5c8 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 16 Jun 2022 00:30:11 +0100 Subject: [PATCH 2/3] Fix regressions from https://gitlab.com/OpenMW/openmw/-/merge_requests/1917 --- components/vfs/filesystemarchive.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/vfs/filesystemarchive.cpp b/components/vfs/filesystemarchive.cpp index 206d9aff0c..0caa4c62b9 100644 --- a/components/vfs/filesystemarchive.cpp +++ b/components/vfs/filesystemarchive.cpp @@ -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 (); + std::u8string 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; } From c3d23b49483ac6b4f99bdf7af06840a293fc1d18 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sat, 18 Jun 2022 22:43:12 +0100 Subject: [PATCH 3/3] Extra hack to make this build on Ubuntu with old CMake --- components/vfs/filesystemarchive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/vfs/filesystemarchive.cpp b/components/vfs/filesystemarchive.cpp index 0caa4c62b9..8b74fb788a 100644 --- a/components/vfs/filesystemarchive.cpp +++ b/components/vfs/filesystemarchive.cpp @@ -34,7 +34,7 @@ namespace VFS if(std::filesystem::is_directory (*i)) continue; - std::u8string proper = i->path ().u8string (); + auto proper = i->path ().u8string (); FileSystemArchiveFile file(std::string((char*)proper.c_str(), proper.size()));