From da739f34459c9dc6726b03a4c8525fe9ac63afc6 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 4 Aug 2024 18:08:48 +0200 Subject: [PATCH] Fix Windows build after 8dcd65bd --- io/nativefilestream.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/io/nativefilestream.cpp b/io/nativefilestream.cpp index 7723c4a..b0473ee 100644 --- a/io/nativefilestream.cpp +++ b/io/nativefilestream.cpp @@ -43,6 +43,7 @@ just "open failed: iostream error". #elif defined(PLATFORM_WINDOWS) #include #include +#include #include // yes, this is needed under Windows (https://msdn.microsoft.com/en-US/library/5yhhz3y7.aspx) #include #endif @@ -346,7 +347,8 @@ void NativeFileStream::setData(FileBuffer data, std::ios_base::openmode openMode std::unique_ptr NativeFileStream::makeWidePath(std::string_view path) { auto ec = std::error_code(); - auto widePath = ::CppUtilities::convertMultiByteToWide(ec, path); + auto size = path.size() < static_cast(std::numeric_limits::max() - 1) ? static_cast(path.size() + 1) : -1; + auto widePath = ::CppUtilities::convertMultiByteToWide(ec, path.data(), size); if (!widePath.first) { throw std::ios_base::failure("converting path to UTF-16", ec); }