copyItem(at:to:strategy:shouldProceedAfterError:shouldCopyItem:)
FileSystem.swift:313- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
func copyItem(at sourcePath: FilePath, to destinationPath: FilePath, strategy copyStrategy: CopyStrategy, shouldProceedAfterError: @escaping (_ source: DirectoryEntry, _ error: Error) async throws -> Void, shouldCopyItem: @escaping (_ source: DirectoryEntry, _ destination: FilePath) async -> Bool) async throws
The item to be copied must be a:
regular file,
symbolic link, or
directory.
shouldCopyItem
can be used to ignore objects not part of this set.
Errors
In addition to the already documented errors these may be thrown
unsupported
if an item to be copied is not a regular file, symbolic link or directory.
Implementation details
This function is platform dependent. On Darwin the copyfile(2)
system call is used and items are cloned where possible. On Linux the sendfile(2)
system call is used.