summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-05 11:15:24 +0200
committerCarl Hetherington <cth@carlh.net>2020-10-13 18:51:11 +0200
commit1db968e0682b079af2dbaa757015c16433c645e3 (patch)
tree9740d0c2fdcf81dae33562a3141ec45a31fa649f
parent1f389ddcb8e5ae66b5b12afd12da136eff5624d4 (diff)
Stop run_ffprobe from changing the current working directory on Windows.
-rw-r--r--src/lib/cross_windows.cc7
1 files changed, 7 insertions, 0 deletions
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<pair<string, string> >