aboutsummaryrefslogtreecommitdiff
path: root/lib/std/tar.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-06-24 16:58:19 -0700
committerGitHub <noreply@github.com>2023-06-24 16:58:19 -0700
commit146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch)
tree67e3db8b444d65c667e314770fc983a7fc8ba293 /lib/std/tar.zig
parent13853bef0df3c90633021850cc6d6abaeea03282 (diff)
parent21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff)
downloadzig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz
zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'lib/std/tar.zig')
-rw-r--r--lib/std/tar.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/tar.zig b/lib/std/tar.zig
index 688d093587..bc9a22fb7c 100644
--- a/lib/std/tar.zig
+++ b/lib/std/tar.zig
@@ -70,8 +70,8 @@ pub const Header = struct {
}
pub fn fileType(header: Header) FileType {
- const result = @enumFromInt(FileType, header.bytes[156]);
- return if (result == @enumFromInt(FileType, 0)) .normal else result;
+ const result = @as(FileType, @enumFromInt(header.bytes[156]));
+ return if (result == @as(FileType, @enumFromInt(0))) .normal else result;
}
fn str(header: Header, start: usize, end: usize) []const u8 {
@@ -117,7 +117,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
start += 512;
const file_size = try header.fileSize();
const rounded_file_size = std.mem.alignForward(u64, file_size, 512);
- const pad_len = @intCast(usize, rounded_file_size - file_size);
+ const pad_len = @as(usize, @intCast(rounded_file_size - file_size));
const unstripped_file_name = try header.fullFileName(&file_name_buffer);
switch (header.fileType()) {
.directory => {
@@ -146,14 +146,14 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
}
// Ask for the rounded up file size + 512 for the next header.
// TODO: https://github.com/ziglang/zig/issues/14039
- const ask = @intCast(usize, @min(
+ const ask = @as(usize, @intCast(@min(
buffer.len - end,
rounded_file_size + 512 - file_off -| (end - start),
- ));
+ )));
end += try reader.readAtLeast(buffer[end..], ask);
if (end - start < ask) return error.UnexpectedEndOfStream;
// TODO: https://github.com/ziglang/zig/issues/14039
- const slice = buffer[start..@intCast(usize, @min(file_size - file_off + start, end))];
+ const slice = buffer[start..@as(usize, @intCast(@min(file_size - file_off + start, end)))];
try file.writeAll(slice);
file_off += slice.len;
start += slice.len;
@@ -167,7 +167,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
},
.global_extended_header, .extended_header => {
if (start + rounded_file_size > end) return error.TarHeadersTooBig;
- start = @intCast(usize, start + rounded_file_size);
+ start = @as(usize, @intCast(start + rounded_file_size));
},
.hard_link => return error.TarUnsupportedFileType,
.symbolic_link => return error.TarUnsupportedFileType,