moveItem(at:to:)

Moves the named file or directory to a new location.

FileSystem.swift:508
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
func moveItem(at sourcePath: FilePath, to destinationPath: FilePath) async throws

Parameters

sourcePath

The path to the item to move.

destinationPath

The path at which to place the item.

Only regular files, symbolic links and directories may be moved. If the item to be is a symbolic link then only the link is moved; the target of the link is not moved.

If the file is moved within to a different logical partition then the file is copied to the new partition before being removed from old partition. If removing the item fails the copied file will not be removed.

Errors

Error codes thrown include:

Implementation details

Uses the rename(2) system call.