Skip to content

Commit 14f4441

Browse files
committed
Improve performance
1 parent 6735660 commit 14f4441

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/Foundation/FileManager+Win32.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,10 @@ extension FileManager {
709709
}
710710

711711
internal func _isExecutableFile(atPath path: String) -> Bool {
712-
var isDirectory: ObjCBool = false
713-
guard fileExists(atPath: path, isDirectory: &isDirectory) else { return false }
714-
guard !isDirectory.boolValue, _isReadableFile(atPath: path) else { return false }
712+
guard let faAttributes: WIN32_FILE_ATTRIBUTE_DATA = try? windowsFileAttributes(atPath: path),
713+
faAttributes.dwFileAttributes & DWORD(FILE_ATTRIBUTE_DIRECTORY) != DWORD(FILE_ATTRIBUTE_DIRECTORY) else {
714+
return false
715+
}
715716
return path.withCString(encodedAs: UTF16.self) {
716717
var binaryType = DWORD(0)
717718
return GetBinaryTypeW($0, &binaryType)

0 commit comments

Comments
 (0)