mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.net.Stream.Reader: init size_err
This code knows in advance that stat() should never be called. closes #24754
This commit is contained in:
parent
e25168d01b
commit
e667884f9b
2 changed files with 7 additions and 1 deletions
|
|
@ -1122,10 +1122,15 @@ pub const Reader = struct {
|
||||||
/// position, use `logicalPos`.
|
/// position, use `logicalPos`.
|
||||||
pos: u64 = 0,
|
pos: u64 = 0,
|
||||||
size: ?u64 = null,
|
size: ?u64 = null,
|
||||||
size_err: ?GetEndPosError = null,
|
size_err: ?SizeError = null,
|
||||||
seek_err: ?Reader.SeekError = null,
|
seek_err: ?Reader.SeekError = null,
|
||||||
interface: std.Io.Reader,
|
interface: std.Io.Reader,
|
||||||
|
|
||||||
|
pub const SizeError = std.os.windows.GetFileSizeError || StatError || error{
|
||||||
|
/// Occurs if, for example, the file handle is a network socket and therefore does not have a size.
|
||||||
|
Streaming,
|
||||||
|
};
|
||||||
|
|
||||||
pub const SeekError = File.SeekError || error{
|
pub const SeekError = File.SeekError || error{
|
||||||
/// Seeking fell back to reading, and reached the end before the requested seek position.
|
/// Seeking fell back to reading, and reached the end before the requested seek position.
|
||||||
/// `pos` remains at the end of the file.
|
/// `pos` remains at the end of the file.
|
||||||
|
|
|
||||||
|
|
@ -2064,6 +2064,7 @@ pub const Stream = struct {
|
||||||
.file = .{ .handle = net_stream.handle },
|
.file = .{ .handle = net_stream.handle },
|
||||||
.mode = .streaming,
|
.mode = .streaming,
|
||||||
.seek_err = error.Unseekable,
|
.seek_err = error.Unseekable,
|
||||||
|
.size_err = error.Streaming,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue