Symlink funcs & support NSURL file-refs

* Also removes most `NSString` usage
* Also does more thorough testing in some places
* Also adds
* Fixes `Path?(_:)` resolving symlinks in some cases
This commit is contained in:
Max Howell
2019-02-11 12:42:50 -05:00
parent 6c84754ad8
commit 709c3fb99d
7 changed files with 515 additions and 49 deletions

View File

@@ -2,7 +2,7 @@ import Foundation
#if os(Linux)
import func Glibc.access
#else
import func Darwin.access
import Darwin
#endif
public extension Path {
@@ -55,4 +55,11 @@ public extension Path {
return false
}
}
/// Returns `true` if the file is a symbolic-link (symlink).
var isSymlink: Bool {
var sbuf = stat()
lstat(string, &sbuf)
return (sbuf.st_mode & S_IFMT) == S_IFLNK
}
}