Open
Description
Zig Version
0.10.0-dev.3922+b98b3252b
Steps to Reproduce
On POSIX-based OS, this succeeds. On Windows, this fails.
const std = @import("std");
const assert = std.debug.assert;
pub fn main() !void {
const file = try std.fs.cwd().createFile("dummy", .{});
defer file.close();
try file.seekBy(10);
const curr_pos = try file.getPos();
assert(curr_pos == 10);
try file.pwriteAll("\xaa", 0);
assert(curr_pos == try file.getPos());
}
Expected Behavior
My question is: should we strive for File.pwrite/pread
(and related) to be platform-independent? My gut is telling me yes but I want to see what others think about this.
Actual Behavior
Currently, File.pwrite/pread
(and related) are platform-dependent.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
wasm: temporarily save curr file pointer before pwriting on Win
gooncreeper commentedon Mar 3, 2025
I would think that a majority of use cases for
pread
andpwrite
would not also mix in seek-based I/O, since it is essentially an optimization to avoid seeking in the first place, so it could be worth leaving the file position unspecified.std.fs: pread/pwrite on Windows reset seek position.