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 {...@@ -1800,12 +1800,12 @@ pub const Writer = struct {
1800 w.pos += n;1800 w.pos += n;
1801 return n;1801 return n;
1802 }1802 }
1803 const copy_file_range_fn = switch (native_os) {1803 const copy_file_range = switch (native_os) {
1804 .freebsd => std.os.freebsd.copy_file_range,1804 .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,1805 .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else void,
1806 else => null,1806 else => void,
1807 };1807 };
1808 if (copy_file_range_fn) |copy_file_range| cfr: {1808 if (copy_file_range != void) cfr: {
1809 if (w.copy_file_range_err != null) break :cfr;1809 if (w.copy_file_range_err != null) break :cfr;
1810 const buffered = limit.slice(file_reader.interface.buffer);1810 const buffered = limit.slice(file_reader.interface.buffer);
1811 if (io_w.end != 0 or buffered.len != 0) return drain(io_w, &.{buffered}, 1);1811 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 {...@@ -124,7 +124,7 @@ pub fn findEndRecord(seekable_stream: anytype, stream_len: u64) !EndRecord {
124124
125 try seekable_stream.seekTo(stream_len - @as(u64, new_loaded_len));125 try seekable_stream.seekTo(stream_len - @as(u64, new_loaded_len));
126 const read_buf: []u8 = buf[buf.len - new_loaded_len ..][0..read_len];126 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);
128 if (len != read_len)128 if (len != read_len)
129 return error.ZipTruncated;129 return error.ZipTruncated;
130 loaded_len = new_loaded_len;130 loaded_len = new_loaded_len;
...@@ -295,7 +295,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -295,7 +295,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
295 if (locator_end_offset > stream_len)295 if (locator_end_offset > stream_len)
296 return error.ZipTruncated;296 return error.ZipTruncated;
297 try stream.seekTo(stream_len - locator_end_offset);297 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);
299 if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))299 if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))
300 return error.ZipBadLocatorSig;300 return error.ZipBadLocatorSig;
301 if (locator.zip64_disk_count != 0)301 if (locator.zip64_disk_count != 0)
...@@ -305,7 +305,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -305,7 +305,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
305305
306 try stream.seekTo(locator.record_file_offset);306 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
310 if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))310 if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))
311 return error.ZipBadEndRecord64Sig;311 return error.ZipBadEndRecord64Sig;
...@@ -357,7 +357,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -357,7 +357,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
357357
358 const header_zip_offset = self.cd_zip_offset + self.cd_record_offset;358 const header_zip_offset = self.cd_zip_offset + self.cd_record_offset;
359 try self.stream.seekTo(header_zip_offset);359 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);
361 if (!std.mem.eql(u8, &header.signature, &central_file_header_sig))361 if (!std.mem.eql(u8, &header.signature, &central_file_header_sig))
362 return error.ZipBadCdOffset;362 return error.ZipBadCdOffset;
363363
...@@ -386,7 +386,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -386,7 +386,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
386386
387 {387 {
388 try self.stream.seekTo(header_zip_offset + @sizeOf(CentralDirectoryFileHeader) + header.filename_len);388 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);
390 if (len != extra.len)390 if (len != extra.len)
391 return error.ZipTruncated;391 return error.ZipTruncated;
392 }392 }
...@@ -449,7 +449,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -449,7 +449,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
449 try stream.seekTo(self.header_zip_offset + @sizeOf(CentralDirectoryFileHeader));449 try stream.seekTo(self.header_zip_offset + @sizeOf(CentralDirectoryFileHeader));
450450
451 {451 {
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);
453 if (len != filename.len)453 if (len != filename.len)
454 return error.ZipBadFileOffset;454 return error.ZipBadFileOffset;
455 }455 }
...@@ -457,7 +457,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -457,7 +457,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
457 const local_data_header_offset: u64 = local_data_header_offset: {457 const local_data_header_offset: u64 = local_data_header_offset: {
458 const local_header = blk: {458 const local_header = blk: {
459 try stream.seekTo(self.file_offset);459 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);
461 };461 };
462 if (!std.mem.eql(u8, &local_header.signature, &local_file_header_sig))462 if (!std.mem.eql(u8, &local_header.signature, &local_file_header_sig))
463 return error.ZipBadFileOffset;463 return error.ZipBadFileOffset;
...@@ -483,7 +483,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -483,7 +483,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
483483
484 {484 {
485 try stream.seekTo(self.file_offset + @sizeOf(LocalFileHeader) + local_header.filename_len);485 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);
487 if (len != extra.len)487 if (len != extra.len)
488 return error.ZipTruncated;488 return error.ZipTruncated;
489 }489 }
...@@ -552,7 +552,7 @@ pub fn Iterator(comptime SeekableStream: type) type {...@@ -552,7 +552,7 @@ pub fn Iterator(comptime SeekableStream: type) type {
552 @as(u64, @sizeOf(LocalFileHeader)) +552 @as(u64, @sizeOf(LocalFileHeader)) +
553 local_data_header_offset;553 local_data_header_offset;
554 try stream.seekTo(local_data_file_offset);554 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);
556 const crc = try decompress(556 const crc = try decompress(
557 self.compression_method,557 self.compression_method,
558 self.uncompressed_size,558 self.uncompressed_size,