Required Instance Methodswift-nio 2.81.0_NIOFileSystem

replaceItem(at:withItemAt:)

Replaces the item at destinationPath with the item at existingPath.

FileSystemProtocol.swift:305
iOS
13.0+
macOS
10.15+
tvOS
13.0+
watchOS
6.0+
func replaceItem(at destinationPath: FilePath, withItemAt existingPath: FilePath) async throws

Parameters

destinationPath

The path of the file or directory to replace.

existingPath

The path of the existing file or directory.

The following error codes may be thrown:

  • notFound if the item at existingPath does not exist,

  • io if the file at existingPath was successfully copied to destinationPath but an error occurred while removing it from existingPath.

Note that other errors may also be thrown.

The item at destinationPath is not required to exist. Note that it is possible to replace a file with a directory and vice versa. After the file or directory at destinationPath has been replaced, the item at existingPath will be removed.