@@ -1635,7 +1635,7 @@ pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenE
1635
1635
errdefer close (fd );
1636
1636
1637
1637
if (flags .write ) {
1638
- const info = try fstat_wasi (fd );
1638
+ const info = try std . os . fstat_wasi (fd );
1639
1639
if (info .filetype == .DIRECTORY )
1640
1640
return error .IsDir ;
1641
1641
}
@@ -4282,7 +4282,7 @@ pub const FStatError = error{
4282
4282
/// Return information about a file descriptor.
4283
4283
pub fn fstat (fd : fd_t ) FStatError ! Stat {
4284
4284
if (native_os == .wasi and ! builtin .link_libc ) {
4285
- return Stat .fromFilestat (try fstat_wasi (fd ));
4285
+ return Stat .fromFilestat (try std . os . fstat_wasi (fd ));
4286
4286
}
4287
4287
if (native_os == .windows ) {
4288
4288
@compileError ("fstat is not yet implemented on Windows" );
@@ -4300,19 +4300,6 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
4300
4300
}
4301
4301
}
4302
4302
4303
- fn fstat_wasi (fd : fd_t ) FStatError ! wasi.filestat_t {
4304
- var stat : wasi.filestat_t = undefined ;
4305
- switch (wasi .fd_filestat_get (fd , & stat )) {
4306
- .SUCCESS = > return stat ,
4307
- .INVAL = > unreachable ,
4308
- .BADF = > unreachable , // Always a race condition.
4309
- .NOMEM = > return error .SystemResources ,
4310
- .ACCES = > return error .AccessDenied ,
4311
- .NOTCAPABLE = > return error .AccessDenied ,
4312
- else = > | err | return unexpectedErrno (err ),
4313
- }
4314
- }
4315
-
4316
4303
pub const FStatAtError = FStatError || error {
4317
4304
NameTooLong ,
4318
4305
FileNotFound ,
@@ -4325,10 +4312,10 @@ pub const FStatAtError = FStatError || error{
4325
4312
/// which is relative to `dirfd` handle.
4326
4313
/// On WASI, `pathname` should be encoded as valid UTF-8.
4327
4314
/// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding.
4328
- /// See also `fstatatZ` and `fstatat_wasi`.
4315
+ /// See also `fstatatZ` and `std.os. fstatat_wasi`.
4329
4316
pub fn fstatat (dirfd : fd_t , pathname : []const u8 , flags : u32 ) FStatAtError ! Stat {
4330
4317
if (native_os == .wasi and ! builtin .link_libc ) {
4331
- const filestat = try fstatat_wasi (dirfd , pathname , .{
4318
+ const filestat = try std . os . fstatat_wasi (dirfd , pathname , .{
4332
4319
.SYMLINK_FOLLOW = (flags & AT .SYMLINK_NOFOLLOW ) == 0 ,
4333
4320
});
4334
4321
return Stat .fromFilestat (filestat );
@@ -4344,7 +4331,7 @@ pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat
4344
4331
/// See also `fstatat`.
4345
4332
pub fn fstatatZ (dirfd : fd_t , pathname : [* :0 ]const u8 , flags : u32 ) FStatAtError ! Stat {
4346
4333
if (native_os == .wasi and ! builtin .link_libc ) {
4347
- const filestat = try fstatat_wasi (dirfd , mem .sliceTo (pathname , 0 ), .{
4334
+ const filestat = try std . os . fstatat_wasi (dirfd , mem .sliceTo (pathname , 0 ), .{
4348
4335
.SYMLINK_FOLLOW = (flags & AT .SYMLINK_NOFOLLOW ) == 0 ,
4349
4336
});
4350
4337
return Stat .fromFilestat (filestat );
@@ -4372,27 +4359,6 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S
4372
4359
}
4373
4360
}
4374
4361
4375
- /// WASI-only. Same as `fstatat` but targeting WASI.
4376
- /// `pathname` should be encoded as valid UTF-8.
4377
- /// See also `fstatat`.
4378
- fn fstatat_wasi (dirfd : fd_t , pathname : []const u8 , flags : wasi.lookupflags_t ) FStatAtError ! wasi.filestat_t {
4379
- var stat : wasi.filestat_t = undefined ;
4380
- switch (wasi .path_filestat_get (dirfd , flags , pathname .ptr , pathname .len , & stat )) {
4381
- .SUCCESS = > return stat ,
4382
- .INVAL = > unreachable ,
4383
- .BADF = > unreachable , // Always a race condition.
4384
- .NOMEM = > return error .SystemResources ,
4385
- .ACCES = > return error .AccessDenied ,
4386
- .FAULT = > unreachable ,
4387
- .NAMETOOLONG = > return error .NameTooLong ,
4388
- .NOENT = > return error .FileNotFound ,
4389
- .NOTDIR = > return error .FileNotFound ,
4390
- .NOTCAPABLE = > return error .AccessDenied ,
4391
- .ILSEQ = > return error .InvalidUtf8 ,
4392
- else = > | err | return unexpectedErrno (err ),
4393
- }
4394
- }
4395
-
4396
4362
pub const KQueueError = error {
4397
4363
/// The per-process limit on the number of open file descriptors has been reached.
4398
4364
ProcessFdQuotaExceeded ,
@@ -4822,7 +4788,7 @@ pub fn faccessat(dirfd: fd_t, path: []const u8, mode: u32, flags: u32) AccessErr
4822
4788
const resolved : RelativePathWasi = .{ .dir_fd = dirfd , .relative_path = path };
4823
4789
4824
4790
const st = blk : {
4825
- break :blk fstatat_wasi (dirfd , path , .{
4791
+ break :blk std . os . fstatat_wasi (dirfd , path , .{
4826
4792
.SYMLINK_FOLLOW = (flags & AT .SYMLINK_NOFOLLOW ) == 0 ,
4827
4793
});
4828
4794
} catch | err | switch (err ) {
0 commit comments