We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 94d6a4a + 2478c02 commit b048f4eCopy full SHA for b048f4e
Foundation/Process.swift
@@ -600,7 +600,15 @@ open class Process: NSObject {
600
DWORD(CREATE_UNICODE_ENVIRONMENT), UnsafeMutableRawPointer(mutating: wszEnvironment),
601
wszCurrentDirectory,
602
&siStartupInfo, &piProcessInfo) {
603
- throw _NSErrorWithWindowsError(GetLastError(), reading: false)
+ let error = GetLastError()
604
+ // If the current directory doesn't exist, Windows
605
+ // throws an ERROR_DIRECTORY. Since POSIX gives an
606
+ // ENOENT, we intercept the error to match the POSIX
607
+ // behaviour
608
+ if error == ERROR_DIRECTORY {
609
+ throw _NSErrorWithWindowsError(DWORD(ERROR_FILE_NOT_FOUND), reading: true)
610
+ }
611
+ throw _NSErrorWithWindowsError(GetLastError(), reading: true)
612
}
613
614
0 commit comments