Skip to content

Commit bb65125

Browse files
committed
Judge executables with API on Windows
1 parent 9966689 commit bb65125

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Foundation/FileManager+Win32.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,11 @@ extension FileManager {
711711
internal func _isExecutableFile(atPath path: String) -> Bool {
712712
var isDirectory: ObjCBool = false
713713
guard fileExists(atPath: path, isDirectory: &isDirectory) else { return false }
714-
return !isDirectory.boolValue && _isReadableFile(atPath: path)
714+
guard !isDirectory.boolValue, _isReadableFile(atPath: path) else { return false }
715+
return path.withCString(encodedAs: UTF16.self) {
716+
var binaryType = DWORD(0)
717+
SaferiIsExecutableFileType($0, false) || GetBinaryTypeW($0, &binaryType)
718+
}
715719
}
716720

717721
internal func _isDeletableFile(atPath path: String) -> Bool {

0 commit comments

Comments
 (0)