1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 20:23:54 +00:00

Use the incremental approach to handle long path

This commit is contained in:
CedricMocquillon 2020-12-12 21:47:50 +01:00
parent 73afc55462
commit e2041de969

View file

@ -126,8 +126,13 @@ namespace Crash
void CrashCatcher::startMonitorProcess(const std::string& crashLogPath) void CrashCatcher::startMonitorProcess(const std::string& crashLogPath)
{ {
WCHAR executablePath[MAX_PATH + 1]; std::wstring executablePath;
GetModuleFileNameW(NULL, executablePath, MAX_PATH + 1); DWORD copied = 0;
do {
executablePath.resize(executablePath.size() + MAX_PATH);
copied = GetModuleFileNameW(nullptr, &executablePath[0], executablePath.size());
} while (copied >= executablePath.size());
executablePath.resize(copied);
memset(mShm->mStartup.mLogFilePath, 0, sizeof(mShm->mStartup.mLogFilePath)); memset(mShm->mStartup.mLogFilePath, 0, sizeof(mShm->mStartup.mLogFilePath));
int length = crashLogPath.length(); int length = crashLogPath.length();
@ -152,7 +157,7 @@ namespace Crash
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&pi, sizeof(pi));
if (!CreateProcessW(executablePath, &argumetns[0], NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) if (!CreateProcessW(&executablePath[0], &argumetns[0], NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
throw std::runtime_error("Could not start crash monitor process"); throw std::runtime_error("Could not start crash monitor process");
waitMonitor(); waitMonitor();