@@ -907,35 +907,35 @@ pub const Dir = struct {
907
907
return self .openFileW (path_w .span (), flags );
908
908
}
909
909
910
- var os_flags : u32 = os .O_CLOEXEC ;
910
+ var os_flags : u32 = os .O . CLOEXEC ;
911
911
// Use the O_ locking flags if the os supports them to acquire the lock
912
912
// atomically.
913
- const has_flock_open_flags = @hasDecl (os , "O_EXLOCK " );
913
+ const has_flock_open_flags = @hasDecl (os . O , "EXLOCK " );
914
914
if (has_flock_open_flags ) {
915
915
// Note that the O_NONBLOCK flag is removed after the openat() call
916
916
// is successful.
917
917
const nonblocking_lock_flag : u32 = if (flags .lock_nonblocking )
918
- os .O_NONBLOCK
918
+ os .O . NONBLOCK
919
919
else
920
920
0 ;
921
921
os_flags |= switch (flags .lock ) {
922
922
.None = > @as (u32 , 0 ),
923
- .Shared = > os .O_SHLOCK | nonblocking_lock_flag ,
924
- .Exclusive = > os .O_EXLOCK | nonblocking_lock_flag ,
923
+ .Shared = > os .O . SHLOCK | nonblocking_lock_flag ,
924
+ .Exclusive = > os .O . EXLOCK | nonblocking_lock_flag ,
925
925
};
926
926
}
927
- if (@hasDecl (os , "O_LARGEFILE " )) {
928
- os_flags |= os .O_LARGEFILE ;
927
+ if (@hasDecl (os . O , "LARGEFILE " )) {
928
+ os_flags |= os .O . LARGEFILE ;
929
929
}
930
930
if (! flags .allow_ctty ) {
931
- os_flags |= os .O_NOCTTY ;
931
+ os_flags |= os .O . NOCTTY ;
932
932
}
933
933
os_flags |= if (flags .write and flags .read )
934
- @as (u32 , os .O_RDWR )
934
+ @as (u32 , os .O . RDWR )
935
935
else if (flags .write )
936
- @as (u32 , os .O_WRONLY )
936
+ @as (u32 , os .O . WRONLY )
937
937
else
938
- @as (u32 , os .O_RDONLY );
938
+ @as (u32 , os .O . RDONLY );
939
939
const fd = if (flags .intended_io_mode != .blocking )
940
940
try std .event .Loop .instance .? .openatZ (self .fd , sub_path , os_flags , 0 )
941
941
else
@@ -947,11 +947,11 @@ pub const Dir = struct {
947
947
if (builtin .target .os .tag != .wasi ) {
948
948
if (! has_flock_open_flags and flags .lock != .None ) {
949
949
// TODO: integrate async I/O
950
- const lock_nonblocking = if (flags .lock_nonblocking ) os .LOCK_NB else @as (i32 , 0 );
950
+ const lock_nonblocking = if (flags .lock_nonblocking ) os .LOCK . NB else @as (i32 , 0 );
951
951
try os .flock (fd , switch (flags .lock ) {
952
952
.None = > unreachable ,
953
- .Shared = > os .LOCK_SH | lock_nonblocking ,
954
- .Exclusive = > os .LOCK_EX | lock_nonblocking ,
953
+ .Shared = > os .LOCK . SH | lock_nonblocking ,
954
+ .Exclusive = > os .LOCK . EX | lock_nonblocking ,
955
955
});
956
956
}
957
957
}
@@ -963,7 +963,7 @@ pub const Dir = struct {
963
963
error .PermissionDenied = > unreachable ,
964
964
else = > | e | return e ,
965
965
};
966
- fl_flags &= ~ @as (usize , os .O_NONBLOCK );
966
+ fl_flags &= ~ @as (usize , os .O . NONBLOCK );
967
967
_ = os .fcntl (fd , os .F_SETFL , fl_flags ) catch | err | switch (err ) {
968
968
error .FileBusy = > unreachable ,
969
969
error .Locked = > unreachable ,
@@ -1038,7 +1038,7 @@ pub const Dir = struct {
1038
1038
/// Same as `createFile` but WASI only.
1039
1039
pub fn createFileWasi (self : Dir , sub_path : []const u8 , flags : File.CreateFlags ) File.OpenError ! File {
1040
1040
const w = os .wasi ;
1041
- var oflags = w .O_CREAT ;
1041
+ var oflags = w .O . CREAT ;
1042
1042
var base : w.rights_t = w .RIGHT_FD_WRITE |
1043
1043
w .RIGHT_FD_DATASYNC |
1044
1044
w .RIGHT_FD_SEEK |
@@ -1054,10 +1054,10 @@ pub const Dir = struct {
1054
1054
base |= w .RIGHT_FD_READ ;
1055
1055
}
1056
1056
if (flags .truncate ) {
1057
- oflags |= w .O_TRUNC ;
1057
+ oflags |= w .O . TRUNC ;
1058
1058
}
1059
1059
if (flags .exclusive ) {
1060
- oflags |= w .O_EXCL ;
1060
+ oflags |= w .O . EXCL ;
1061
1061
}
1062
1062
const fd = try os .openatWasi (self .fd , sub_path , 0x0 , oflags , 0x0 , base , 0x0 );
1063
1063
return File { .handle = fd };
@@ -1072,24 +1072,24 @@ pub const Dir = struct {
1072
1072
1073
1073
// Use the O_ locking flags if the os supports them to acquire the lock
1074
1074
// atomically.
1075
- const has_flock_open_flags = @hasDecl (os , "O_EXLOCK " );
1075
+ const has_flock_open_flags = @hasDecl (os . O , "EXLOCK " );
1076
1076
// Note that the O_NONBLOCK flag is removed after the openat() call
1077
1077
// is successful.
1078
1078
const nonblocking_lock_flag : u32 = if (has_flock_open_flags and flags .lock_nonblocking )
1079
- os .O_NONBLOCK
1079
+ os .O . NONBLOCK
1080
1080
else
1081
1081
0 ;
1082
1082
const lock_flag : u32 = if (has_flock_open_flags ) switch (flags .lock ) {
1083
1083
.None = > @as (u32 , 0 ),
1084
- .Shared = > os .O_SHLOCK | nonblocking_lock_flag ,
1085
- .Exclusive = > os .O_EXLOCK | nonblocking_lock_flag ,
1084
+ .Shared = > os .O . SHLOCK | nonblocking_lock_flag ,
1085
+ .Exclusive = > os .O . EXLOCK | nonblocking_lock_flag ,
1086
1086
} else 0 ;
1087
1087
1088
- const O_LARGEFILE = if (@hasDecl (os , "O_LARGEFILE " )) os .O_LARGEFILE else 0 ;
1089
- const os_flags = lock_flag | O_LARGEFILE | os .O_CREAT | os .O_CLOEXEC |
1090
- (if (flags .truncate ) @as (u32 , os .O_TRUNC ) else 0 ) |
1091
- (if (flags .read ) @as (u32 , os .O_RDWR ) else os .O_WRONLY ) |
1092
- (if (flags .exclusive ) @as (u32 , os .O_EXCL ) else 0 );
1088
+ const O_LARGEFILE = if (@hasDecl (os . O , "LARGEFILE " )) os .O . LARGEFILE else 0 ;
1089
+ const os_flags = lock_flag | O_LARGEFILE | os .O . CREAT | os .O . CLOEXEC |
1090
+ (if (flags .truncate ) @as (u32 , os .O . TRUNC ) else 0 ) |
1091
+ (if (flags .read ) @as (u32 , os .O . RDWR ) else os .O . WRONLY ) |
1092
+ (if (flags .exclusive ) @as (u32 , os .O . EXCL ) else 0 );
1093
1093
const fd = if (flags .intended_io_mode != .blocking )
1094
1094
try std .event .Loop .instance .? .openatZ (self .fd , sub_path_c , os_flags , flags .mode )
1095
1095
else
@@ -1101,11 +1101,11 @@ pub const Dir = struct {
1101
1101
if (builtin .target .os .tag != .wasi ) {
1102
1102
if (! has_flock_open_flags and flags .lock != .None ) {
1103
1103
// TODO: integrate async I/O
1104
- const lock_nonblocking = if (flags .lock_nonblocking ) os .LOCK_NB else @as (i32 , 0 );
1104
+ const lock_nonblocking = if (flags .lock_nonblocking ) os .LOCK . NB else @as (i32 , 0 );
1105
1105
try os .flock (fd , switch (flags .lock ) {
1106
1106
.None = > unreachable ,
1107
- .Shared = > os .LOCK_SH | lock_nonblocking ,
1108
- .Exclusive = > os .LOCK_EX | lock_nonblocking ,
1107
+ .Shared = > os .LOCK . SH | lock_nonblocking ,
1108
+ .Exclusive = > os .LOCK . EX | lock_nonblocking ,
1109
1109
});
1110
1110
}
1111
1111
}
@@ -1117,7 +1117,7 @@ pub const Dir = struct {
1117
1117
error .PermissionDenied = > unreachable ,
1118
1118
else = > | e | return e ,
1119
1119
};
1120
- fl_flags &= ~ @as (usize , os .O_NONBLOCK );
1120
+ fl_flags &= ~ @as (usize , os .O . NONBLOCK );
1121
1121
_ = os .fcntl (fd , os .F_SETFL , fl_flags ) catch | err | switch (err ) {
1122
1122
error .FileBusy = > unreachable ,
1123
1123
error .Locked = > unreachable ,
@@ -1262,7 +1262,7 @@ pub const Dir = struct {
1262
1262
return self .realpathW (pathname_w .span (), out_buffer );
1263
1263
}
1264
1264
1265
- const flags = if (builtin .os .tag == .linux ) os .O_PATH | os .O_NONBLOCK | os .O_CLOEXEC else os .O_NONBLOCK | os .O_CLOEXEC ;
1265
+ const flags = if (builtin .os .tag == .linux ) os .O . PATH | os .O . NONBLOCK | os .O . CLOEXEC else os .O . NONBLOCK | os .O . CLOEXEC ;
1266
1266
const fd = os .openatZ (self .fd , pathname , flags , 0 ) catch | err | switch (err ) {
1267
1267
error .FileLocksNotSupported = > unreachable ,
1268
1268
else = > | e | return e ,
@@ -1423,7 +1423,7 @@ pub const Dir = struct {
1423
1423
// TODO do we really need all the rights here?
1424
1424
const inheriting : w.rights_t = w .RIGHT_ALL ^ w .RIGHT_SOCK_SHUTDOWN ;
1425
1425
1426
- const result = os .openatWasi (self .fd , sub_path , symlink_flags , w .O_DIRECTORY , 0x0 , base , inheriting );
1426
+ const result = os .openatWasi (self .fd , sub_path , symlink_flags , w .O . DIRECTORY , 0x0 , base , inheriting );
1427
1427
const fd = result catch | err | switch (err ) {
1428
1428
error .FileTooBig = > unreachable , // can't happen for directories
1429
1429
error .IsDir = > unreachable , // we're providing O_DIRECTORY
@@ -1442,12 +1442,12 @@ pub const Dir = struct {
1442
1442
const sub_path_w = try os .windows .cStrToPrefixedFileW (sub_path_c );
1443
1443
return self .openDirW (sub_path_w .span ().ptr , args );
1444
1444
}
1445
- const symlink_flags : u32 = if (args .no_follow ) os .O_NOFOLLOW else 0x0 ;
1445
+ const symlink_flags : u32 = if (args .no_follow ) os .O . NOFOLLOW else 0x0 ;
1446
1446
if (! args .iterate ) {
1447
- const O_PATH = if (@hasDecl (os , "O_PATH " )) os .O_PATH else 0 ;
1448
- return self .openDirFlagsZ (sub_path_c , os .O_DIRECTORY | os .O_RDONLY | os .O_CLOEXEC | O_PATH | symlink_flags );
1447
+ const O_PATH = if (@hasDecl (os . O , "PATH " )) os .O . PATH else 0 ;
1448
+ return self .openDirFlagsZ (sub_path_c , os .O . DIRECTORY | os .O . RDONLY | os .O . CLOEXEC | O_PATH | symlink_flags );
1449
1449
} else {
1450
- return self .openDirFlagsZ (sub_path_c , os .O_DIRECTORY | os .O_RDONLY | os .O_CLOEXEC | symlink_flags );
1450
+ return self .openDirFlagsZ (sub_path_c , os .O . DIRECTORY | os .O . RDONLY | os .O . CLOEXEC | symlink_flags );
1451
1451
}
1452
1452
}
1453
1453
@@ -2132,7 +2132,7 @@ pub fn cwd() Dir {
2132
2132
} else if (builtin .os .tag == .wasi and ! builtin .link_libc ) {
2133
2133
@compileError ("WASI doesn't have a concept of cwd(); use std.fs.wasi.PreopenList to get available Dir handles instead" );
2134
2134
} else {
2135
- return Dir { .fd = os .AT_FDCWD };
2135
+ return Dir { .fd = os .AT . FDCWD };
2136
2136
}
2137
2137
}
2138
2138
0 commit comments