Initializerswift-nio 2.81.0_NIOFileSystem->Swift
init(contentsOf:maximumSizeAllowed:fileSystem:)
Reads the contents of the file at the path into a String.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
init(contentsOf path: FilePath, maximumSizeAllowed: ByteCount, fileSystem: some FileSystemProtocol) async throws
Parameters
- path
The path of the file to read.
- maximumSizeAllowed
The maximum size of file which can be read, in bytes, as a
ByteCount
. If the file is larger than this, an error is thrown.- fileSystem
The
FileSystemProtocol
instance to use to read the file.
Throws
If the file is larger than maximumSizeAllowed
, an resourceExhausted
error will be thrown.