mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +01:00
[util] Implement createDirectory function
This commit is contained in:
parent
629238ac36
commit
9bfa470581
@ -1,6 +1,4 @@
|
|||||||
#include "util_env.h"
|
#include "util_env.h"
|
||||||
#include <vector>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "./com/com_include.h"
|
#include "./com/com_include.h"
|
||||||
|
|
||||||
@ -33,16 +31,6 @@ namespace dxvk::env {
|
|||||||
void setThreadName(const std::string& name) {
|
void setThreadName(const std::string& name) {
|
||||||
using SetThreadDescriptionProc = void (WINAPI *) (HANDLE, PCWSTR);
|
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");
|
HMODULE module = ::GetModuleHandleW(L"kernel32.dll");
|
||||||
|
|
||||||
if (module == nullptr)
|
if (module == nullptr)
|
||||||
@ -51,8 +39,16 @@ namespace dxvk::env {
|
|||||||
auto proc = reinterpret_cast<SetThreadDescriptionProc>(
|
auto proc = reinterpret_cast<SetThreadDescriptionProc>(
|
||||||
::GetProcAddress(module, "SetThreadDescription"));
|
::GetProcAddress(module, "SetThreadDescription"));
|
||||||
|
|
||||||
if (proc != nullptr)
|
if (proc != nullptr) {
|
||||||
|
auto wideName = str::tows(name);
|
||||||
(*proc)(::GetCurrentThread(), wideName.data());
|
(*proc)(::GetCurrentThread(), wideName.data());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool createDirectory(const std::string& path) {
|
||||||
|
auto widePath = str::tows(path);
|
||||||
|
return !!CreateDirectoryW(widePath.data(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,12 @@ namespace dxvk::env {
|
|||||||
*/
|
*/
|
||||||
void setThreadName(const std::string& 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