From: Carl Hetherington Date: Mon, 5 Oct 2020 09:15:24 +0000 (+0200) Subject: Stop run_ffprobe from changing the current working directory on Windows. X-Git-Tag: v2.15.104~41 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=1db968e0682b079af2dbaa757015c16433c645e3 Stop run_ffprobe from changing the current working directory on Windows. --- diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc index cba674fef..23a5da599 100644 --- a/src/lib/cross_windows.cc +++ b/src/lib/cross_windows.cc @@ -126,6 +126,9 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) return; } + wchar_t previous_dir[512]; + GetCurrentDirectory (sizeof(previous_dir), previous_dir); + wchar_t dir[512]; MultiByteToWideChar (CP_UTF8, 0, directory_containing_executable().string().c_str(), -1, dir, sizeof(dir)); SetCurrentDirectory (dir); @@ -149,12 +152,14 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) ZeroMemory (&process_info, sizeof (process_info)); if (!CreateProcess (0, command, 0, 0, TRUE, CREATE_NO_WINDOW, 0, 0, &startup_info, &process_info)) { LOG_ERROR_NC (N_("ffprobe call failed (could not CreateProcess)")); + SetCurrentDirectory (previous_dir); return; } FILE* o = fopen_boost (out, "w"); if (!o) { LOG_ERROR_NC (N_("ffprobe call failed (could not create output file)")); + SetCurrentDirectory (previous_dir); return; } @@ -175,6 +180,8 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) CloseHandle (process_info.hProcess); CloseHandle (process_info.hThread); CloseHandle (child_stderr_read); + + SetCurrentDirectory (previous_dir); } list >