Skip to content

Commit

Permalink
Fix Windows default search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Dec 7, 2021
1 parent 06c38d3 commit ed19978
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Sources/TSCBasic/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,15 @@ public final class Process {
if GetSystemDirectoryW(&buffer, .init(buffer.count)) > 0 {
searchPaths.append(AbsolutePath(String(decodingCString: buffer, as: UTF16.self)))
}
// The 16-bit Windows system directory
if let systemDrive = ProcessEnv.vars["systemdrive"],
let systemPath = try? AbsolutePath(validating: "\(systemDrive))\\System") {
searchPaths.append(systemPath)
}
// The Windows directory
if GetWindowsDirectoryW(&buffer, .init(buffer.count)) > 0 {
searchPaths.append(AbsolutePath(String(decodingCString: buffer, as: UTF16.self)))
let windowsDirectory = String(decodingCString: buffer, as: UTF16.self)
// The 16-bit Windows system directory
searchPaths.append(AbsolutePath("\(windowsDirectory)\\System"))
// The Windows directory
searchPaths.append(AbsolutePath(windowsDirectory))
}
#endif
searchPaths.append(contentsOf: envSearchPaths)
// Lookup and cache the executable path.
let value = lookupExecutablePath(
filename: program,
currentWorkingDirectory: cwdOpt,
Expand Down

0 comments on commit ed19978

Please sign in to comment.