From 1db968e0682b079af2dbaa757015c16433c645e3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 5 Oct 2020 11:15:24 +0200 Subject: [PATCH] Stop run_ffprobe from changing the current working directory on Windows. --- src/lib/cross_windows.cc | 7 +++++++ 1 file changed, 7 insertions(+) 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 > -- 2.30.2