@@ -24,7 +24,7 @@ pub const FileType = enum(u8) {
24
24
gnu_long_link = 'K' ,
25
25
_ ,
26
26
27
- pub const sentinel = @intToEnum (FileType , 0xff );
27
+ pub const sentinel = @enumFromInt (FileType , 0xff );
28
28
29
29
pub const NamedTypesBitset = std .StaticBitSet (128 );
30
30
@@ -35,21 +35,21 @@ pub const FileType = enum(u8) {
35
35
.symbolic_link , .character_special , .block_special , .fifo ,
36
36
.contiguous ,
37
37
}) | ft |
38
- result .set (@enumToInt (ft ));
38
+ result .set (@intFromEnum (ft ));
39
39
break :blk result ;
40
40
};
41
41
42
42
pub fn isNamedType (ft : FileType ) bool {
43
43
return
44
44
// verify not beyond NamedTypesBitset.bit_length to avoid assertion
45
45
// failure in std.bit_set
46
- @enumToInt (ft ) < NamedTypesBitset .bit_length and
47
- named_types_bitset .isSet (@enumToInt (ft ));
46
+ @intFromEnum (ft ) < NamedTypesBitset .bit_length and
47
+ named_types_bitset .isSet (@intFromEnum (ft ));
48
48
}
49
49
50
50
pub fn tagName (ft : FileType ) ? []const u8 {
51
51
return inline for (std .meta .fields (FileType )) | f | {
52
- if (@enumToInt (ft ) == f .value ) break f .name ;
52
+ if (@intFromEnum (ft ) == f .value ) break f .name ;
53
53
} else null ;
54
54
}
55
55
};
@@ -76,12 +76,12 @@ fn parseNumeric(b: []const u8) !i64 {
76
76
// data bytes and treat the value as an unsigned number.
77
77
78
78
// inv = 0xff if negative else 0
79
- const inv = @as (u8 , @boolToInt (b [0 ] & 0x40 != 0 )) * 0xff ;
79
+ const inv = @as (u8 , @intFromBool (b [0 ] & 0x40 != 0 )) * 0xff ;
80
80
81
81
var x : u64 = 0 ;
82
82
for (0.. b .len ) | i | {
83
83
// ignore the signal bit in first byte
84
- const mask = @as (u8 , 0xff ) >> @boolToInt (i == 0 );
84
+ const mask = @as (u8 , 0xff ) >> @intFromBool (i == 0 );
85
85
const c = b [i ] ^ inv & mask ;
86
86
if (x > 0x00ff_ffff_ffff_ffff ) return error .Overflow ;
87
87
x = x << 8 | c ;
@@ -442,14 +442,14 @@ pub const Header = struct {
442
442
// TODO remove when unused
443
443
pub fn format (h : Header , comptime _ : []const u8 , _ : fmt.FormatOptions , writer : anytype ) ! void {
444
444
const tagname = inline for (std .meta .fields (FileType )) | field | {
445
- if (@enumToInt (h .type ) == field .value ) break field .name ;
445
+ if (@intFromEnum (h .type ) == field .value ) break field .name ;
446
446
} else "null" ;
447
447
try writer .print ("type={s} size={} name={s} mtime={} mode=0o{o}" , .{ tagname , h .size , h .name , h .mtime , h .mode });
448
448
try debugFormatSet (h .fmt , writer );
449
449
}
450
450
451
451
fn structField (comptime field_enum : std .meta .FieldEnum (Header )) std.builtin.Type.StructField {
452
- return @typeInfo (Header ).Struct .fields [@enumToInt (field_enum )];
452
+ return @typeInfo (Header ).Struct .fields [@intFromEnum (field_enum )];
453
453
}
454
454
455
455
fn fieldDefault (comptime field : std.builtin.Type.StructField ) field.type {
@@ -766,7 +766,7 @@ pub fn HeaderIterator(comptime Reader: type) type {
766
766
size : usize ,
767
767
outbuf : * std .ArrayListUnmanaged (u8 ),
768
768
) ! []u8 {
769
- var want = mem .alignForwardGeneric (usize , size , block_len );
769
+ var want = mem .alignForward (usize , size , block_len );
770
770
outbuf .items .len = 0 ;
771
771
var w = outbuf .writer (self .allocator );
772
772
var buf : [block_len ]u8 = undefined ;
@@ -1080,7 +1080,7 @@ fn makeSymLink(dir: fs.Dir, target_path: []const u8, symlink_path: []const u8) !
1080
1080
};
1081
1081
defer file .close ();
1082
1082
const stat = try file .stat ();
1083
- break :blk stat .kind == .Directory ;
1083
+ break :blk stat .kind == .directory ;
1084
1084
};
1085
1085
try dir .symLink (target_path , symlink_path , .{ .is_directory = is_directory });
1086
1086
}
@@ -1146,7 +1146,7 @@ pub fn pipeToFileSystem(
1146
1146
defer file .close ();
1147
1147
const size = math .cast (usize , header .size ) orelse
1148
1148
return error .Header ;
1149
- const want = mem .alignForwardGeneric (usize , size , block_len );
1149
+ const want = mem .alignForward (usize , size , block_len );
1150
1150
var lim_reader = std .io .limitedReader (reader , want );
1151
1151
var bytes_left = size ;
1152
1152
while (true ) {
@@ -1195,7 +1195,7 @@ pub fn pipeToFileSystem(
1195
1195
format .setIntersection (fmt_pax );
1196
1196
},
1197
1197
else = > {
1198
- log .err ("unsupported type '{?s}':{}" , .{ header .type .tagName (), @enumToInt (header .type ) });
1198
+ log .err ("unsupported type '{?s}':{}" , .{ header .type .tagName (), @intFromEnum (header .type ) });
1199
1199
return error .TarUnexpectedFileType ;
1200
1200
},
1201
1201
}
0 commit comments