mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[common] Add a way to set the process startup directory (#63)
This will be needed later for switching to sftp, since calling lcd in sftp is tricky to get right (e.g. may or may not require /cygwin/c on Windows, depending on whether sftp is native or not).
This commit is contained in:
@@ -719,6 +719,10 @@ absl::Status WinProcess::Start() {
|
||||
Util::GetLastWin32Error());
|
||||
}
|
||||
|
||||
std::wstring startup_dir = Util::Utf8ToWideStr(start_info_.startup_dir);
|
||||
const wchar_t* startup_dir_cstr =
|
||||
!startup_dir.empty() ? startup_dir.c_str() : nullptr;
|
||||
|
||||
// Start the child process.
|
||||
success = CreateProcess(NULL, // No module name (use command line)
|
||||
command_cstr,
|
||||
@@ -727,8 +731,7 @@ absl::Status WinProcess::Start() {
|
||||
TRUE, // Inherit handles
|
||||
ToCreationFlags(start_info_.flags),
|
||||
NULL, // Use parent's environment block
|
||||
NULL, // Use parent's starting directory
|
||||
&si, &process_info_->pi);
|
||||
startup_dir_cstr, &si, &process_info_->pi);
|
||||
|
||||
if (!success) {
|
||||
return MakeStatus("CreateProcess() failed: %s", Util::GetLastWin32Error());
|
||||
|
||||
Reference in New Issue
Block a user