Instance Methodswift-nio 2.72.0_NIOFileSystem
readToEnd(fromAbsoluteOffset:maximumSizeAllowed:)
Returns the contents of a file by loading it into memory.
FileHandleProtocol.swift:335- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
func readToEnd(fromAbsoluteOffset offset: Int64 = 0, maximumSizeAllowed: ByteCount) async throws -> ByteBuffer
Parameters
- offset
The absolute offset into the file to read from. Defaults to zero.
- maximumSizeAllowed
The maximum size of file to read, as a
ByteCount
.
Returns
The bytes read from the file.
Throws
FileSystemError
with code resourceExhausted
if there are more bytes to read than maximumBytesAllowed
. unsupported
if file is unseekable and offset
is not 0.
See also
func bufferedReader(startingAtAbsoluteOffset: Int64, capacity: ByteCount
) -> BufferedReader<Self> Creates a new
BufferedReader
for this file handle.func readChunks(chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: Range<Int64>, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: UnboundedRange, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: ClosedRange<Int64>, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: PartialRangeFrom<Int64>, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: PartialRangeThrough<Int64>, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.
func readChunks(in: PartialRangeUpTo<Int64>, chunkLength: ByteCount
) -> FileChunks Returns an asynchronous sequence of chunks read from the file.