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,11 +123,17 @@ public extension Path {
return rv 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 @inlinable
func delete() throws { func delete() throws {
if exists {
try FileManager.default.removeItem(at: url) try FileManager.default.removeItem(at: url)
} }
}
/** /**
Creates an empty file at this path. Creates an empty file at this path.