pub fn readFileAlloc(
dir: Dir,
io: Io,
/// On Windows, should be encoded as [WTF-8](https://wtf-8.codeberg.page/).
/// On WASI, should be encoded as valid UTF-8.
/// On other platforms, an opaque sequence of bytes with no particular encoding.
sub_path: []const u8,
/// Used to allocate the result.
gpa: Allocator,
/// If reached or exceeded, `error.StreamTooLong` is returned instead.
limit: Io.Limit,
) ReadFileAllocError![]u8 dir: Dirio: Iosub_path: []const u8On Windows, should be encoded as WTF-8. On WASI, should be encoded as valid UTF-8. On other platforms, an opaque sequence of bytes with no particular encoding.
gpa: AllocatorUsed to allocate the result.
limit: Io.LimitIf reached or exceeded, error.StreamTooLong is returned instead.
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343pub fn readFileAlloc(
dir: Dir,
io: Io,
/// On Windows, should be encoded as [WTF-8](https://wtf-8.codeberg.page/).
/// On WASI, should be encoded as valid UTF-8.
/// On other platforms, an opaque sequence of bytes with no particular encoding.
sub_path: []const u8,
/// Used to allocate the result.
gpa: Allocator,
/// If reached or exceeded, `error.StreamTooLong` is returned instead.
limit: Io.Limit,
) ReadFileAllocError![]u8 {
return readFileAllocOptions(dir, io, sub_path, gpa, limit, .of(u8), null);
}
Reads all the bytes from the named file. On success, caller owns returned buffer.
If the file size is already known, a better alternative is to initialize a
File.Reader.If the file size cannot be obtained, an error is returned. If this is a realistic possibility, a better alternative is to initialize a
File.Readerwhich handles this seamlessly.