Effortless path operations in Swift.
Add this to your Package.swift
.Package(url: "https://github.com/kylef/Pathkit.git, majorVersion: 0, minor: 7)
let path = Path("/usr/bin/swift")
let path = Path("/usr/bin") + Path("swift")
var path = Path("/usr/bin")
path += Path("swift")
path.isAbsolute
path.isRelative
path.exists
path.isDirectory
let absolutePath = path.absolute
This cleans up any redundant ..
or .
and double slashes in paths.
let normalizedPath = path.normalized
path.delete()
path.move(newPath)
Path.current
Path.current = "/usr/bin"
path.chdir {
// Path.current would be set to path during execution of this closure
}
path.children
path.read()
path.write("Hello World!")
let paths = Path.glob("*.swift")
Kyle Fuller
PathKit is licensed under the BSD License.