Delete is a noop if file doesn’t exist

Closes #11.
This commit is contained in:
Max Howell
2019-01-26 11:01:41 -05:00
parent 6d8712f4d6
commit 356a1b3ac2

View File

@@ -123,10 +123,16 @@ public extension Path {
return rv
}
/// Deletes the path, recursively if a directory.
/**
Deletes the path, recursively if a directory.
- Note: noop: if the path doesnt exist
*Path.swift* doesnt error if desired end result preexists.
*/
@inlinable
func delete() throws {
try FileManager.default.removeItem(at: url)
if exists {
try FileManager.default.removeItem(at: url)
}
}
/**