Add rename

This commit is contained in:
Max Howell
2019-01-31 08:38:00 -05:00
parent eb34ac4af8
commit c6e840b9b6
3 changed files with 44 additions and 5 deletions

View File

@@ -174,6 +174,13 @@ public extension Path {
}
return self
}
@discardableResult
func rename(_ newname: String) throws -> Path {
let newpath = parent/newname
try FileManager.default.moveItem(atPath: string, toPath: newpath.string)
return newpath
}
}
/// Options for `Path.mkdir(_:)`