mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 18:13:19 +00:00
std.fs.File: fix missing end of stream
This commit is contained in:
parent
5ac895c820
commit
b0d825948a
@ -1158,20 +1158,21 @@ pub const Reader = struct {
|
||||
// end.
|
||||
fallback: {
|
||||
if (r.size_err == null and r.seek_err == null) break :fallback;
|
||||
var trash_buffer: [std.atomic.cache_line]u8 = undefined;
|
||||
var trash_buffer: [128]u8 = undefined;
|
||||
const trash = &trash_buffer;
|
||||
if (is_windows) {
|
||||
const n = windows.ReadFile(file.handle, trash, null) catch |err| {
|
||||
r.err = err;
|
||||
return error.ReadFailed;
|
||||
};
|
||||
if (n == 0) return error.EndOfStream;
|
||||
r.pos = pos + n;
|
||||
return n;
|
||||
}
|
||||
var iovecs: [max_buffers_len]std.posix.iovec = undefined;
|
||||
var iovecs_i: usize = 0;
|
||||
var remaining = @intFromEnum(limit);
|
||||
while (remaining > 0 and iovecs_i >= iovecs.len) {
|
||||
while (remaining > 0 and iovecs_i < iovecs.len) {
|
||||
iovecs[iovecs_i] = .{ .base = trash, .len = @min(trash.len, remaining) };
|
||||
remaining -= iovecs[iovecs_i].len;
|
||||
iovecs_i += 1;
|
||||
@ -1180,6 +1181,7 @@ pub const Reader = struct {
|
||||
r.err = err;
|
||||
return error.ReadFailed;
|
||||
};
|
||||
if (n == 0) return error.EndOfStream;
|
||||
r.pos = pos + n;
|
||||
return n;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user