Instance Method
readFile(at:chunkSize:offset:byteCount:)
Reads the contents of a file at the supplied path in chunks.
func readFile(at path: String, chunkSize: Int = NonBlockingFileIO.defaultChunkSize, offset: Int64? = nil, byteCount: Int? = nil) async throws -> FileIO.FileChunks
Parameters
pathPath to file on the disk.
chunkSizeMaximum size for the file data chunks.
offsetThe offset to start reading from.
byteCountThe number of bytes to read from the file. If
nil, the file will be read to the end.
Return Value
FileChunks containing the file data chunks.
Discussion
For try await chunk in try await req.fileio.readFile(at: “/path/to/file.txt”) { print(“chunk: (data)”) }
Warning
It’s the caller’s responsibility to close the file handle provided in FileIO.FileChunks when finished.