zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3c8e1bc25b6d122ce1295e2e33bb9f54ae801ec0 (tree)
parent 90743881cf10c4f90da4a8c187997e9eab4d17d5
Author: LemonBoy <thatlemon@gmail.com>
Date:   Fri,  4 Sep 2020 12:48:36 +0200

std: Fix for 32bit systems

Diffstat:
Mlib/std/fs.zig | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/std/fs.zig b/lib/std/fs.zig @@ -1457,7 +1457,10 @@ pub const Dir = struct { var file = try self.openFile(file_path, .{}); defer file.close(); - const stat_size = size_hint orelse try file.getEndPos(); + // If the file size doesn't fit a usize it'll be certainly greater than + // `max_bytes` + const stat_size = size_hint orelse math.cast(usize, try file.getEndPos()) catch + return error.FileTooBig; return file.readToEndAllocOptions(allocator, max_bytes, stat_size, alignment, optional_sentinel); }