Skip to content

Commit 3091008

Browse files
neonichupyrtsa
andcommitted
Use URL.resourceValues() for symlink detection
This should provide a significant performance improvement on macOS. See [this](#400 (comment)]) for more discussion on non-macOS platforms. Co-authored-by: Pyry Jahkola <[email protected]>
1 parent b3d8257 commit 3091008

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/TSCBasic/FileSystem.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ private struct LocalFileSystem: FileSystem {
370370
}
371371

372372
func isSymlink(_ path: AbsolutePath) -> Bool {
373-
let attrs = try? FileManager.default.attributesOfItem(atPath: path.pathString)
374-
return attrs?[.type] as? FileAttributeType == .typeSymbolicLink
373+
let url = NSURL(fileURLWithPath: path.pathString)
374+
let result = try? url.resourceValues(forKeys: [.isSymbolicLinkKey])
375+
return (result?[.isSymbolicLinkKey] as? Bool) == true
375376
}
376377

377378
func isReadable(_ path: AbsolutePath) -> Bool {

0 commit comments

Comments
 (0)