Skip to content

Commit 4cd733b

Browse files
committed
fix(windows): use 0 for file mode on Windows (zig 0.16.0 compat)
zig 0.16.0 changed std.fs.File.Permissions on Windows from an options struct (with .toMode() returning a POSIX mode integer) to an enum (Windows-specific DWORD). Calling .toMode() on Windows now fails to compile with: src\archiver.zig:97:65: error: no field or member function named 'toMode' in 'Io.File.Permissions__enum_2757' Fix: write 0 for the file mode on Windows. POSIX mode bits don't apply there, and the archive is read on the same machine that wrote it, so the receiver can derive permissions from its own filesystem. On non-Windows platforms, keep the existing behavior of writing @intcast(stat.permissions.toMode()).
1 parent 5150c83 commit 4cd733b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/archiver.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ pub fn pack_directory(arena: Allocator, path: []const u8, archive_path: []const
9494
if (stat.size > 0) {
9595
assert(stat.size == try reader.streamRemaining(writer));
9696
}
97-
try writer.writeInt(usize, @intCast(stat.permissions.toMode()), .little);
97+
// On Windows, std.fs.File.Permissions is an enum (no
98+
// .toMode() method), and POSIX mode bits don't apply.
99+
// Write 0 — the archive is read on the same machine that
100+
// wrote it, so the receiver can derive permissions from
101+
// its own filesystem.
102+
const mode: usize = if (builtin.os.tag == .windows)
103+
0
104+
else
105+
@intCast(stat.permissions.toMode());
106+
try writer.writeInt(usize, mode, .little);
98107

99108
count += 1;
100109

0 commit comments

Comments
 (0)