Structureswift-nio 2.72.0_NIOFileSystem
ReadWriteFileHandle
Implements ReadableAndWritableFileHandleProtocol
by making system calls to interact with the local file system.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
struct ReadWriteFileHandle
See also
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.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 DirectoryFileHandle
Implements
DirectoryFileHandleProtocol
by making system calls to interact with the local file system.func withFileSystem<Result>(numberOfThreads: Int, (FileSystem) async throws -> Result
) async throws -> Result Provides temporary scoped access to a
FileSystem
with the given number of threads.
Citizens in _NIOFileSystem
Conformances
protocol FileHandleProtocol
A handle for a file system object.
protocol ReadableFileHandleProtocol
A handle for reading data from an open file.
protocol WritableFileHandleProtocol
A file handle suitable for writing.
Show implementation details (1)
Hide implementation details
protocol _HasFileHandle
Provides a
FileHandle
.
Instance members
let fileHandle: FileHandle
func close(makeChangesVisible: Bool
) async throws func readChunk(fromAbsoluteOffset: Int64, length: ByteCount
) async throws -> ByteBuffer func readChunks(in: Range<Int64>, chunkLength: ByteCount
) -> FileChunks func resize(to: ByteCount
) async throws func setTimes(lastAccess: FileInfo.Timespec?, lastDataModification: FileInfo.Timespec?
) async throws func write(contentsOf: some (Sequence<UInt8> & Sendable), toAbsoluteOffset: Int64
) async throws -> Int64
Instance features
func addPermissions(FilePermissions
) async throws -> FilePermissions func attributeNames(
) async throws -> [String] func bufferedReader(startingAtAbsoluteOffset: Int64, capacity: ByteCount
) -> BufferedReader<Self> Creates a new
BufferedReader
for this file handle.func bufferedWriter(startingAtAbsoluteOffset: Int64, capacity: ByteCount
) -> BufferedWriter<Self> Creates a new
BufferedWriter
for this file handle.func close(
) async throws func detachUnsafeFileDescriptor(
) throws -> FileDescriptor func info(
) async throws -> FileInfo func readChunks(chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readToEnd(fromAbsoluteOffset: Int64, maximumSizeAllowed: ByteCount
) async throws -> ByteBuffer Returns the contents of a file by loading it into memory.
func removePermissions(FilePermissions
) async throws -> FilePermissions func removeValueForAttribute(String
) async throws func replacePermissions(FilePermissions
) async throws func setLastAccessTime(to: FileInfo.Timespec
) async throws Sets the file’s last access time to the given time.
func setLastDataModificationTime(to: FileInfo.Timespec
) async throws Sets the file’s last data modification time to the given time.
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(some (Sendable & RandomAccessCollection<UInt8>), attribute: String
) async throws func valueForAttribute(String
) async throws -> [UInt8] func withBufferedWriter<Result>(startingAtAbsoluteOffset: Int64, capacity: ByteCount, execute: (inout BufferedWriter<Self>) async throws -> Result
) async throws -> Result Convenience function that creates a buffered reader, executes the closure that writes the contents into the buffer and calls ‘flush()’.
func withUnsafeDescriptor<R>(@escaping (FileDescriptor) throws -> R
) async throws -> R func write(contentsOf: ByteBuffer, toAbsoluteOffset: Int64
) async throws -> Int64 Write the readable bytes of the
ByteBuffer
to the open file.