mirror of
https://github.com/apple/swift-nio
synced 2026-11-23 04:34:23 +00:00
Adds the changes from https://github.com/apple/swift-nio/pull/3508 to the `_NIOFileSystem`. ### Motivation: We have added capability to overwrite regular files and symbolic links to `NIOFS` `FileSystem.copyItem` in https://github.com/apple/swift-nio/pull/3508. Now we want to port the same logic to `_NIOFileSystem`. ### Modifications: - Adds a new `FileSystemProtocol.copyItem` requirement with `replaceExisting: bool` parameter along with a default implementation. - Adds an implementation of the new `FileSystemProtocol.copyItem` requirement to `_NIOFileSystem`'s `FileSystem` struct for regular files and symbolic links. ### Notes It seems that the tests for `FileSystem` are only in `NIOFS` - so no tests are added in this PR.
1.3 KiB
1.3 KiB
_NIOFileSystem/FileSystemProtocol
Topics
Opening files with managed lifecycles
Files and directories can be opened and have their lifecycles managed by using the following methods:
withFileHandle(forReadingAt:options:execute:)withFileHandle(forWritingAt:options:execute:)withFileHandle(forReadingAndWritingAt:options:execute:)withDirectoryHandle(atPath:options:execute:)
Opening files
Files and directories can be opened using the following methods. The caller is responsible for closing it to avoid leaking resources.
openFile(forReadingAt:)openFile(forWritingAt:options:)openFile(forReadingAndWritingAt:options:)openDirectory(atPath:options:)
File information
info(forFileAt:infoAboutSymbolicLink:)
Symbolic links
createSymbolicLink(at:withDestination:)destinationOfSymbolicLink(at:)
Managing files
copyItem(at:to:strategy:shouldProceedAfterError:shouldCopyItem:)copyItem(at:to:strategy:replaceExisting:shouldProceedAfterError:shouldCopyItem:)removeItem(at:)moveItem(at:to:)replaceItem(at:withItemAt:)createDirectory(at:withIntermediateDirectories:permissions:)
System directories
currentWorkingDirectorytemporaryDirectorywithTemporaryDirectory(prefix:options:execute:)