Skip to content

windows: File.pwrite/pread alters the file pointer #12783

Open
@kubkon

Description

@kubkon

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

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-windowsquestionNo questions on the issue tracker, please.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions