@@ -24,7 +24,7 @@ pub const FileType = enum(u8) {
24
24
gnu_long_link = 'K' ,
25
25
_ ,
26
26
27
- pub const sentinel = @enumFromInt (FileType , 0xff );
27
+ pub const sentinel : FileType = @enumFromInt (0xff );
28
28
29
29
pub const NamedTypesBitset = std .StaticBitSet (128 );
30
30
@@ -89,9 +89,9 @@ fn parseNumeric(b: []const u8) !i64 {
89
89
if (x >= 0x8000_0000_0000_0000 ) return error .Overflow ;
90
90
91
91
return if (inv == 0 )
92
- @bitCast (i64 , x )
92
+ @as (i64 , @bitCast ( x ) )
93
93
else
94
- ~ @bitCast (i64 , x );
94
+ ~ @as (i64 , @bitCast ( x ) );
95
95
}
96
96
97
97
return try parseOctal (b );
@@ -303,8 +303,8 @@ pub fn mergePax(kv: [2][]const u8, hdr: *Header) !void {
303
303
.linkname = > hdr .linkname = v ,
304
304
.uname = > hdr .uname = v ,
305
305
.gname = > hdr .gname = v ,
306
- .uid = > hdr .uid = @truncate (i32 , try fmt .parseInt (i64 , v , 10 )),
307
- .gid = > hdr .gid = @truncate (i32 , try fmt .parseInt (i64 , v , 10 )),
306
+ .uid = > hdr .uid = @truncate (try fmt .parseInt (i64 , v , 10 )),
307
+ .gid = > hdr .gid = @truncate (try fmt .parseInt (i64 , v , 10 )),
308
308
.atime = > hdr .atime = try parsePaxTime (v ),
309
309
.ctime = > hdr .ctime = try parsePaxTime (v ),
310
310
.mtime = > hdr .mtime = try parsePaxTime (v ),
@@ -453,10 +453,9 @@ pub const Header = struct {
453
453
}
454
454
455
455
fn fieldDefault (comptime field : std.builtin.Type.StructField ) field.type {
456
- return @ptrCast (
457
- * const field .type ,
458
- @alignCast (@alignOf (field .type ), field .default_value ),
459
- ).* ;
456
+ return @as (* const field .type , @ptrCast (
457
+ @alignCast (field .default_value ),
458
+ )).* ;
460
459
}
461
460
462
461
/// copy all fields from `new_hdr` to `hdr`, but skipping any fields that
@@ -505,11 +504,7 @@ pub const Header = struct {
505
504
};
506
505
507
506
pub fn unixTime (tv_sec : i64 , tv_nsec : i64 ) ! i128 {
508
- const result = @bitCast (i128 , [_ ]i64 {
509
- try math .mul (i64 , tv_sec , time .ns_per_s ),
510
- tv_nsec ,
511
- });
512
- return result ;
507
+ return @bitCast ([_ ]i64 { try math .mul (i64 , tv_sec , time .ns_per_s ), tv_nsec });
513
508
}
514
509
515
510
pub const block_len = 512 ;
@@ -545,29 +540,29 @@ const V7Header = extern struct {
545
540
else
546
541
bytes_ [i ];
547
542
unsigned += c ;
548
- signed += @bitCast (i8 , c );
543
+ signed += @as (i8 , @bitCast ( c ) );
549
544
}
550
545
return .{ unsigned , signed };
551
546
}
552
547
553
548
inline fn ustar (h : * const V7Header ) * const UstarHeader {
554
- return @ptrCast (* const UstarHeader , h );
549
+ return @ptrCast (h );
555
550
}
556
551
inline fn star (h : * const V7Header ) * const StarHeader {
557
- return @ptrCast (* const StarHeader , h );
552
+ return @ptrCast (h );
558
553
}
559
554
inline fn gnu (h : * const V7Header ) * const GnuHeader {
560
- return @ptrCast (* const GnuHeader , h );
555
+ return @ptrCast (h );
561
556
}
562
557
inline fn bytes (h : * const V7Header ) * const [block_len ]u8 {
563
- return @ptrCast (* const [ block_len ] u8 , h );
558
+ return @ptrCast (h );
564
559
}
565
560
566
561
// Magics used to identify various formats.
567
562
const magic_gnu = "ustar " ;
568
563
const version_gnu = " \x00 " ;
569
564
const magic_version_gnu = mem .readIntBig (u64 , magic_gnu ++ version_gnu );
570
- const magic_ustar = @truncate (u48 , mem .readIntBig (u64 , "ustar\x00\x00\x00 " ) >> 16 );
565
+ const magic_ustar : u48 = @truncate (mem .readIntBig (u64 , "ustar\x00\x00\x00 " ) >> 16 );
571
566
const version_ustar = "00" ; // unused. left only for documentation
572
567
const trailer_star = mem .readIntBig (u32 , "tar\x00 " );
573
568
@@ -578,7 +573,7 @@ const V7Header = extern struct {
578
573
return fmt_unknown ;
579
574
580
575
const magic_version = h .ustar ().magicVersion ();
581
- const magic = @truncate (u48 , magic_version >> 16 );
576
+ const magic : u48 = @truncate (magic_version >> 16 );
582
577
583
578
return if (magic == magic_ustar and
584
579
mem .readIntBig (u32 , & h .star ().trailer ) == trailer_star )
@@ -607,7 +602,7 @@ const UstarHeader = extern struct {
607
602
__padding : [12 ]u8 ,
608
603
609
604
pub fn magicVersion (ustar : * const UstarHeader ) u64 {
610
- return mem .readIntBig (u64 , @ptrCast ([* ]const u8 , & ustar .magic )[0.. 8]);
605
+ return mem .readIntBig (u64 , @as ([* ]const u8 , @ptrCast ( & ustar .magic ) )[0.. 8]);
611
606
}
612
607
613
608
comptime {
@@ -722,14 +717,14 @@ pub fn HeaderIterator(comptime Reader: type) type {
722
717
.gnu_long_name = > {
723
718
format .setIntersection (fmt_gnu );
724
719
gnu_long_name = mem .sliceTo (try self .readBlocks (
725
- @intCast (usize , hdr .size ),
720
+ @intCast (hdr .size ),
726
721
& self .name_buf ,
727
722
), 0 );
728
723
},
729
724
.gnu_long_link = > {
730
725
format .setIntersection (fmt_gnu );
731
726
gnu_long_link = mem .sliceTo (try self .readBlocks (
732
- @intCast (usize , hdr .size ),
727
+ @intCast (hdr .size ),
733
728
& self .linkname_buf ,
734
729
), 0 );
735
730
},
@@ -779,11 +774,11 @@ pub fn HeaderIterator(comptime Reader: type) type {
779
774
want -= block_len ;
780
775
}
781
776
if (want != 0 ) return error .UnexpectedEndOfStream ;
782
- return outbuf .items [0.. @intCast (usize , size )];
777
+ return outbuf .items [0.. @intCast (size )];
783
778
}
784
779
785
780
inline fn v7Header (self : Self ) * const V7Header {
786
- return @ptrCast (* const V7Header , self .buf );
781
+ return @ptrCast (self .buf );
787
782
}
788
783
789
784
/// Reads n bytes from reader. Returns the following depending on n:
@@ -1011,7 +1006,7 @@ const Pax = struct {
1011
1006
1012
1007
/// return the most significant, 'top' half of the time as an i64
1013
1008
fn truncateTime (t : i128 ) i64 {
1014
- return @truncate (i64 , t >> 64 );
1009
+ return @truncate (t >> 64 );
1015
1010
}
1016
1011
1017
1012
const is_windows = builtin .os .tag == .windows ;
@@ -1036,7 +1031,7 @@ fn setFileProperties(file: fs.File, header: Header, options: Options) !void {
1036
1031
// match gnu tar behavior on linux while using
1037
1032
// header.mode does not
1038
1033
const mode = try file .mode (); // header.mode
1039
- var modebits = std .StaticBitSet (32 ){ .mask = @intCast (u32 , mode ) };
1034
+ var modebits = std .StaticBitSet (32 ){ .mask = @intCast (mode ) };
1040
1035
// copy the user exe bit to the group and other exe bits
1041
1036
// these bit indices count from the right:
1042
1037
// u g o
0 commit comments