Skip to content
Permalink
Browse files

Merge PR #2838: mumble_exe: when using a versioned root, set the CWD …

…to it.
  • Loading branch information...
mkrautz committed Feb 11, 2017
2 parents 5bbd804 + 03cfe38 commit 289d0d4c44d18125831651f5f46ce0208efe79e9
Showing with 19 additions and 16 deletions.
  1. +19 −16 src/mumble_exe/mumble_exe.cpp
@@ -48,22 +48,6 @@ static const std::wstring GetExecutableDirPath() {
return exe_path.append(L"\\");
}

// ConfigureEnvironment prepares mumble.exe's environment to
// run mumble_app.dll.
static bool ConfigureEnvironment() {
const std::wstring exe_path = GetExecutableDirPath();

// Remove the current directory from the DLL search path.
if (!SetDllDirectoryW(L""))
return false;

// Set mumble.exe's directory as the current working directory.
if (!SetCurrentDirectoryW(exe_path.c_str()))
return false;

return true;
}

// GetVersionedRootPath returns the versioned root path if
// Mumble is configured to work with versioned paths.
// If Mumble is not configured for versioned paths, this
@@ -82,6 +66,25 @@ static const std::wstring GetVersionedRootPath() {
return std::wstring();
}

// ConfigureEnvironment prepares mumble.exe's environment to
// run mumble_app.dll.
static bool ConfigureEnvironment() {
// Remove the current directory from the DLL search path.
if (!SetDllDirectoryW(L""))
return false;

// Set the versioned root as the working directory if one is available.
// If not, use the directory containing mumble.exe as the working directory.
std::wstring cwd = GetVersionedRootPath();
if (cwd.empty()) {
cwd = GetExecutableDirPath();
}
if (!SetCurrentDirectoryW(cwd.c_str()))
return false;

return true;
}

// GetAbsoluteMumbleAppDllPath returns the absolute path to
// mumble_app.dll - the DLL containing the Mumble client
// application code.

0 comments on commit 289d0d4

Please sign in to comment.
You can’t perform that action at this time.