1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 19:24:11 +01:00

[util] Implement createDirectory function

This commit is contained in:
Philip Rebohle 2019-02-11 21:36:23 +01:00
parent 629238ac36
commit 9bfa470581
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 17 additions and 13 deletions

View File

@ -1,6 +1,4 @@
#include "util_env.h"
#include <vector>
#include <cstdlib>
#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<WCHAR> 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<SetThreadDescriptionProc>(
::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);
}
}

View File

@ -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);
}