diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-12-18 22:03:10 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-23 22:15:10 -0800 |
| commit | 7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c (patch) | |
| tree | 6d1d5f066c72636fc1da74fddce4e44e211b431f /lib/std/Io/File | |
| parent | 21d0264c61ac29724b98187aa87d192f97b52425 (diff) | |
| download | zig-7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c.tar.gz zig-7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c.zip | |
std: update remaining unit tests for std.Io API changes
Diffstat (limited to 'lib/std/Io/File')
| -rw-r--r-- | lib/std/Io/File/Reader.zig | 4 | ||||
| -rw-r--r-- | lib/std/Io/File/Writer.zig | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/std/Io/File/Reader.zig b/lib/std/Io/File/Reader.zig index 2359fad722..0c573c9ae1 100644 --- a/lib/std/Io/File/Reader.zig +++ b/lib/std/Io/File/Reader.zig @@ -18,8 +18,8 @@ io: Io, file: File, err: ?Error = null, mode: Mode = .positional, -/// Tracks the true seek position in the file. To obtain the logical -/// position, use `logicalPos`. +/// Tracks the true seek position in the file. To obtain the logical position, +/// use `logicalPos`. pos: u64 = 0, size: ?u64 = null, size_err: ?SizeError = null, diff --git a/lib/std/Io/File/Writer.zig b/lib/std/Io/File/Writer.zig index 56a1c09340..3487416719 100644 --- a/lib/std/Io/File/Writer.zig +++ b/lib/std/Io/File/Writer.zig @@ -11,8 +11,8 @@ io: Io, file: File, err: ?Error = null, mode: Mode = .positional, -/// Tracks the true seek position in the file. To obtain the logical -/// position, add the buffer size to this value. +/// Tracks the true seek position in the file. To obtain the logical position, +/// use `logicalPos`. pos: u64 = 0, write_file_err: ?WriteFileError = null, seek_err: ?SeekError = null, @@ -221,6 +221,10 @@ pub fn seekTo(w: *Writer, offset: u64) (SeekError || Io.Writer.Error)!void { try seekToUnbuffered(w, offset); } +pub fn logicalPos(w: *const Writer) u64 { + return w.pos + w.interface.end; +} + /// Asserts that no data is currently buffered. pub fn seekToUnbuffered(w: *Writer, offset: u64) SeekError!void { assert(w.interface.buffered().len == 0); |
