Files
swift-nio/Sources/_NIOFileSystem/Docs.docc/Extensions/FileSystemProtocol.md
Joseph Heck 6b33489e64 Updates to present docs on _NIOFileSystem (#3477)
This re-enables documentation lost during refactoring work, under the
target _NIOFileSystem

resolves #3474 

### Motivation:

During the refactoring of NIOFileSystem and recent Swift updates, the
mechanism to "shadow" symbols using `@_exported import` has stopped
working for documentation and imports for symbols, which means that
_NIOFileSystem is the target that needs to host the documentation for
this (for now)

### Modifications:

Moves DocC catalog into _NIOFileSystem target, and updates
disambiguation hashes on overloaded symbols in order to verify no
warnings are presented while generating documentation.
Updates .spi.yml to present _NIOFileSystem instead of NIOFileSystem

### Result:

Previous documentation should be available again, although at a slightly
different URI structure within Swift Package Index.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2026-01-13 14:22:46 +00:00

1.2 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:)
  • createSymbolicLink(at:withDestination:)
  • destinationOfSymbolicLink(at:)

Managing files

  • copyItem(at:to:strategy:shouldProceedAfterError:shouldCopyItem:)
  • removeItem(at:)
  • moveItem(at:to:)
  • replaceItem(at:withItemAt:)
  • createDirectory(at:withIntermediateDirectories:permissions:)

System directories

  • currentWorkingDirectory
  • temporaryDirectory
  • withTemporaryDirectory(prefix:options:execute:)