Files
swift-nio/Sources/NIOFS/Docs.docc/Extensions/DirectoryFileHandleProtocol.md
T
George Barnett a18bddb0ac Add back NIOFileSystem (#3380)
Motivation:

We accidentally removed the 'NIOFileSystem' module from the
'_NIOFileSystem' product in the last release.

Modifications:

- Rename 'NIOFileSystem' and 'NIOFileSystemFoundationCompat' to 'NIOFS'
  and 'NIOFSFoundationCompat'
- Add back 'NIOFileSystem' which re-exports '_NIOFileSystem' (there was
  no publicly available 'NIOFileSystemFoundationCompat' module to
  remove, only '_NIOFileSystemFoundationCompat').

Result:

Fewer breaks
2025-09-23 17:29:01 +01:00

875 B

NIOFileSystem/DirectoryFileHandleProtocol

Topics

Iterating a directory

  • listContents()

Opening files with managed lifecycles

Open files and directories at paths relative to the directory handle. These methods manage the lifecycle of the handles by closing them when the execute closure returns.

  • withFileHandle(forReadingAt:options:execute:)
  • withFileHandle(forWritingAt:options:execute:)
  • withFileHandle(forReadingAndWritingAt:options:execute:)
  • withDirectoryHandle(atPath:options:execute:)

Opening files

Open files and directories at paths relative to the directory handle. These methods return the handle to the caller who is responsible for closing it.

  • openFile(forReadingAt:options:)
  • openFile(forWritingAt:options:)
  • openFile(forReadingAndWritingAt:options:)
  • openDirectory(atPath:options:)