Refactor rename -> rename(to:)

This commit is contained in:
Max Howell
2019-01-31 10:15:34 -05:00
parent 889d825b3a
commit 49ef073e34
3 changed files with 14 additions and 7 deletions

View File

@@ -175,8 +175,16 @@ public extension Path {
return self
}
/**
Renames the file at path.
Path.root.foo.bar.rename(to: "baz") // => /foo/baz
- Parameter to: the new basename for the file
- Returns: The renamed path.
*/
@discardableResult
func rename(_ newname: String) throws -> Path {
func rename(to newname: String) throws -> Path {
let newpath = parent/newname
try FileManager.default.moveItem(atPath: string, toPath: newpath.string)
return newpath