DirectoryFileHandle
Implements DirectoryFileHandleProtocol
by making system calls to interact with the local file system.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
struct DirectoryFileHandle
Implements DirectoryFileHandleProtocol
by making system calls to interact with the local file system.
struct DirectoryFileHandle
import _NIOFileSystem
A file system library for Swift.
protocol DirectoryFileHandleProtocol : FileHandleProtocol
A handle suitable for directories.
struct FileSystem
A file system which interacts with the local system. The file system uses a thread pool to perform system calls.
struct FileHandle
Implements FileHandleProtocol
by making system calls to interact with the local file system.
protocol FileHandleProtocol
A handle for a file system object.
struct ReadFileHandle
Implements ReadableFileHandleProtocol
by making system calls to interact with the local file system.
struct WriteFileHandle
Implements WritableFileHandleProtocol
by making system calls to interact with the local file system.
struct ReadWriteFileHandle
Implements ReadableAndWritableFileHandleProtocol
by making system calls to interact with the local file system.
func withFileSystem<Result>(numberOfThreads: Int, _ body: (FileSystem) async throws -> Result) async throws -> Result
Provides temporary scoped access to a FileSystem
with the given number of threads.
protocol _HasFileHandle : FileHandleProtocol
Provides a FileHandle
.
let fileHandle: FileHandle
func listContents(recursive: Bool) -> DirectoryEntries
func openDirectory(atPath path: FilePath, options: OpenOptions.Directory) async throws -> DirectoryFileHandle
func openFile(forReadingAndWritingAt path: FilePath, options: OpenOptions.Write) async throws -> ReadWriteFileHandle
func openFile(forReadingAt path: FilePath, options: OpenOptions.Read) async throws -> ReadFileHandle
func openFile(forWritingAt path: FilePath, options: OpenOptions.Write) async throws -> WriteFileHandle
func addPermissions(_ permissions: FilePermissions) async throws -> FilePermissions
func attributeNames() async throws -> [String]
func close() async throws
func detachUnsafeFileDescriptor() throws -> FileDescriptor
func info() async throws -> FileInfo
func listContents() -> DirectoryEntries
Returns an AsyncSequence
of entries in the open directory.
func removePermissions(_ permissions: FilePermissions) async throws -> FilePermissions
func removeValueForAttribute(_ name: String) async throws
func replacePermissions(_ permissions: FilePermissions) async throws
func setLastAccessTime(to time: FileInfo.Timespec) async throws
Sets the file’s last access time to the given time.
func setLastDataModificationTime(to time: FileInfo.Timespec) async throws
Sets the file’s last data modification time to the given time.
func setTimes(lastAccess: FileInfo.Timespec?, lastDataModification: FileInfo.Timespec?) async throws
func synchronize() async throws
func touch() async throws
Sets the file’s last access and last data modification times to the current time.
func updateValueForAttribute(_ bytes: some (Sendable & RandomAccessCollection<UInt8>), attribute name: String) async throws
func valueForAttribute(_ name: String) async throws -> [UInt8]
func withDirectoryHandle<Result>(atPath path: FilePath, options: OpenOptions.Directory = OpenOptions.Directory(), execute body: (_ directory: Self) async throws -> Result) async throws -> Result
Opens the directory at the given path and provides scoped access to it.
func withFileHandle<Result>(forReadingAndWritingAt path: FilePath, options: OpenOptions.Write = .newFile(replaceExisting: false), execute body: (_ readWrite: ReadWriteFileHandle) async throws -> Result) async throws -> Result
Opens the file at the given path and provides scoped read-write access to it.
func withFileHandle<Result>(forReadingAt path: FilePath, options: OpenOptions.Read = OpenOptions.Read(), execute body: (_ read: ReadFileHandle) async throws -> Result) async throws -> Result
Opens the file at the given path and provides scoped read access to it.
func withFileHandle<Result>(forWritingAt path: FilePath, options: OpenOptions.Write = .newFile(replaceExisting: false), execute body: (_ write: WriteFileHandle) async throws -> Result) async throws -> Result
Opens the file at the given path and provides scoped write access to it.
func withUnsafeDescriptor<R>(_ execute: @escaping (FileDescriptor) throws -> R) async throws -> R where R : Sendable