From 1c08725acd1cd750903a1a6a97b8372dbbdf191f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 28 Jul 2022 19:41:05 +0200 Subject: [PATCH] [util] Use transcodeString in createDirectory function --- src/util/util_env.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index a759ae34..1b0901f6 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -115,9 +115,14 @@ namespace dxvk::env { bool createDirectory(const std::string& path) { #ifdef _WIN32 - WCHAR widePath[MAX_PATH]; - str::tows(path.c_str(), widePath); - return !!CreateDirectoryW(widePath, nullptr); + std::array widePath; + + size_t length = str::transcodeString( + widePath.data(), widePath.size() - 1, + path.data(), path.size()); + + widePath[length] = L'\0'; + return !!CreateDirectoryW(widePath.data(), nullptr); #else return std::filesystem::create_directories(path); #endif