diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index 42ab8b869..0a9ca60fd 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -1,6 +1,4 @@ #include "util_env.h" -#include -#include #include "./com/com_include.h" @@ -33,16 +31,6 @@ namespace dxvk::env { void setThreadName(const std::string& name) { using SetThreadDescriptionProc = void (WINAPI *) (HANDLE, PCWSTR); - int nameLen = ::MultiByteToWideChar( - CP_ACP, 0, name.c_str(), name.length() + 1, - nullptr, 0); - - std::vector wideName(nameLen); - - ::MultiByteToWideChar( - CP_ACP, 0, name.c_str(), name.length() + 1, - wideName.data(), nameLen); - HMODULE module = ::GetModuleHandleW(L"kernel32.dll"); if (module == nullptr) @@ -51,8 +39,16 @@ namespace dxvk::env { auto proc = reinterpret_cast( ::GetProcAddress(module, "SetThreadDescription")); - if (proc != nullptr) + if (proc != nullptr) { + auto wideName = str::tows(name); (*proc)(::GetCurrentThread(), wideName.data()); + } + } + + + bool createDirectory(const std::string& path) { + auto widePath = str::tows(path); + return !!CreateDirectoryW(widePath.data(), nullptr); } } diff --git a/src/util/util_env.h b/src/util/util_env.h index bbbfa3a17..f327bf7a4 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -30,5 +30,13 @@ namespace dxvk::env { * \param [in] name Thread name */ void setThreadName(const std::string& name); + + /** + * \brief Creates a directory + * + * \param [in] path Path to directory + * \returns \c true on success + */ + bool createDirectory(const std::string& path); }