1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[util] Add method to retrieve full exe path

This commit is contained in:
Philip Rebohle 2019-08-17 11:46:40 +02:00
parent d38607c9be
commit c934333a5c
2 changed files with 18 additions and 7 deletions

View File

@ -13,19 +13,24 @@ namespace dxvk::env {
std::string getExeName() { std::string getExeName() {
std::vector<WCHAR> exePath; std::string fullPath = getExePath();
exePath.resize(MAX_PATH + 1);
DWORD len = ::GetModuleFileNameW(NULL, exePath.data(), MAX_PATH);
exePath.resize(len);
std::string fullPath = str::fromws(exePath.data());
auto n = fullPath.find_last_of('\\'); auto n = fullPath.find_last_of('\\');
return (n != std::string::npos) return (n != std::string::npos)
? fullPath.substr(n + 1) ? fullPath.substr(n + 1)
: fullPath; : fullPath;
} }
std::string getExePath() {
std::vector<WCHAR> exePath;
exePath.resize(MAX_PATH + 1);
DWORD len = ::GetModuleFileNameW(NULL, exePath.data(), MAX_PATH);
exePath.resize(len);
return str::fromws(exePath.data());
}
void setThreadName(const std::string& name) { void setThreadName(const std::string& name) {

View File

@ -25,6 +25,12 @@ namespace dxvk::env {
*/ */
std::string getExeName(); std::string getExeName();
/**
* \brief Gets full path to executable
* \returns Path to executable
*/
std::string getExePath();
/** /**
* \brief Sets name of the calling thread * \brief Sets name of the calling thread
* \param [in] name Thread name * \param [in] name Thread name