mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-03 13:24:20 +01:00
[util] Implement createDirectory function
This commit is contained in:
parent
629238ac36
commit
9bfa470581
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user