From c934333a5cdf5e0aee03c2565808577a7b6b2adf Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 17 Aug 2019 11:46:40 +0200 Subject: [PATCH] [util] Add method to retrieve full exe path --- src/util/util_env.cpp | 19 ++++++++++++------- src/util/util_env.h | 6 ++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index afd2a6507..7644e07fa 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -13,19 +13,24 @@ namespace dxvk::env { std::string getExeName() { - std::vector exePath; - exePath.resize(MAX_PATH + 1); - - DWORD len = ::GetModuleFileNameW(NULL, exePath.data(), MAX_PATH); - exePath.resize(len); - - std::string fullPath = str::fromws(exePath.data()); + std::string fullPath = getExePath(); auto n = fullPath.find_last_of('\\'); return (n != std::string::npos) ? fullPath.substr(n + 1) : fullPath; } + + + std::string getExePath() { + std::vector 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) { diff --git a/src/util/util_env.h b/src/util/util_env.h index f327bf7a4..2f0008052 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -25,6 +25,12 @@ namespace dxvk::env { */ std::string getExeName(); + /** + * \brief Gets full path to executable + * \returns Path to executable + */ + std::string getExePath(); + /** * \brief Sets name of the calling thread * \param [in] name Thread name