authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-03 19:39:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:53-07:00
log64899076624f24025728484ffd6762c94e15173f
tree71eeea43dae15333e7fd475209c325bf6f7858b3
parentf4720e14072fc4aa45fd2c985a676d4140ecc06a

std.zip: work around deprecated API


2 files changed, 13 insertions(+), 13 deletions(-)

lib/std/fs/File.zig+4-4
......@@ -1800,12 +1800,12 @@ pub const Writer = struct {
18001800 w.pos += n;
18011801 return n;
18021802 }
1803 const copy_file_range_fn = switch (native_os) {
1803 const copy_file_range = switch (native_os) {
18041804 .freebsd => std.os.freebsd.copy_file_range,
1805 .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else null,
1806 else => null,
1805 .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else void,
1806 else => void,
18071807 };
1808 if (copy_file_range_fn) |copy_file_range| cfr: {
1808 if (copy_file_range != void) cfr: {
18091809 if (w.copy_file_range_err != null) break :cfr;
18101810 const buffered = limit.slice(file_reader.interface.buffer);
18111811 if (io_w.end != 0 or buffered.len != 0) return drain(io_w, &.{buffered}, 1);
lib/std/zip.zig+9-9
......@@ -124,7 +124,7 @@ pub fn findEndRecord(seekable_stream: anytype, stream_len: u64) !EndRecord {
124124
125125 try seekable_stream.seekTo(stream_len - @as(u64, new_loaded_len));
126126 const read_buf: []u8 = buf[buf.len - new_loaded_len ..][0..read_len];
127 const len = try seekable_stream.context.reader().readAll(read_buf);
127 const len = try (if (@TypeOf(seekable_stream.context) == std.fs.File) seekable_stream.context.deprecatedReader() else seekable_stream.context.reader()).readAll(read_buf);
128128 if (len != read_len)
129129 return error.ZipTruncated;
130130 loaded_len = new_loaded_len;
......@@ -295,7 +295,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
295295 if (locator_end_offset > stream_len)
296296 return error.ZipTruncated;
297297 try stream.seekTo(stream_len - locator_end_offset);
298 const locator = try stream.context.reader().readStructEndian(EndLocator64, .little);
298 const locator = try (if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()).readStructEndian(EndLocator64, .little);
299299 if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))
300300 return error.ZipBadLocatorSig;
301301 if (locator.zip64_disk_count != 0)
......@@ -305,7 +305,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
305305
306306 try stream.seekTo(locator.record_file_offset);
307307
308 const record64 = try stream.context.reader().readStructEndian(EndRecord64, .little);
308 const record64 = try (if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()).readStructEndian(EndRecord64, .little);
309309
310310 if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))
311311 return error.ZipBadEndRecord64Sig;
......@@ -357,7 +357,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
357357
358358 const header_zip_offset = self.cd_zip_offset + self.cd_record_offset;
359359 try self.stream.seekTo(header_zip_offset);
360 const header = try self.stream.context.reader().readStructEndian(CentralDirectoryFileHeader, .little);
360 const header = try (if (@TypeOf(self.stream.context) == std.fs.File) self.stream.context.deprecatedReader() else self.stream.context.reader()).readStructEndian(CentralDirectoryFileHeader, .little);
361361 if (!std.mem.eql(u8, &header.signature, &central_file_header_sig))
362362 return error.ZipBadCdOffset;
363363
......@@ -386,7 +386,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
386386
387387 {
388388 try self.stream.seekTo(header_zip_offset + @sizeOf(CentralDirectoryFileHeader) + header.filename_len);
389 const len = try self.stream.context.reader().readAll(extra);
389 const len = try (if (@TypeOf(self.stream.context) == std.fs.File) self.stream.context.deprecatedReader() else self.stream.context.reader()).readAll(extra);
390390 if (len != extra.len)
391391 return error.ZipTruncated;
392392 }
......@@ -449,7 +449,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
449449 try stream.seekTo(self.header_zip_offset + @sizeOf(CentralDirectoryFileHeader));
450450
451451 {
452 const len = try stream.context.reader().readAll(filename);
452 const len = try (if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()).readAll(filename);
453453 if (len != filename.len)
454454 return error.ZipBadFileOffset;
455455 }
......@@ -457,7 +457,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
457457 const local_data_header_offset: u64 = local_data_header_offset: {
458458 const local_header = blk: {
459459 try stream.seekTo(self.file_offset);
460 break :blk try stream.context.reader().readStructEndian(LocalFileHeader, .little);
460 break :blk try (if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()).readStructEndian(LocalFileHeader, .little);
461461 };
462462 if (!std.mem.eql(u8, &local_header.signature, &local_file_header_sig))
463463 return error.ZipBadFileOffset;
......@@ -483,7 +483,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
483483
484484 {
485485 try stream.seekTo(self.file_offset + @sizeOf(LocalFileHeader) + local_header.filename_len);
486 const len = try stream.context.reader().readAll(extra);
486 const len = try (if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()).readAll(extra);
487487 if (len != extra.len)
488488 return error.ZipTruncated;
489489 }
......@@ -552,7 +552,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
552552 @as(u64, @sizeOf(LocalFileHeader)) +
553553 local_data_header_offset;
554554 try stream.seekTo(local_data_file_offset);
555 var limited_reader = std.io.limitedReader(stream.context.reader(), self.compressed_size);
555 var limited_reader = std.io.limitedReader((if (@TypeOf(stream.context) == std.fs.File) stream.context.deprecatedReader() else stream.context.reader()), self.compressed_size);
556556 const crc = try decompress(
557557 self.compression_method,
558558 self.uncompressed_size,