@@ -247,7 +247,7 @@ pub const Iterator = switch (native_os) {
247
247
.NOTDIR = > unreachable ,
248
248
.INVAL = > unreachable ,
249
249
.ACCES = > return error .AccessDenied ,
250
- .PERM = > return error .AccessDenied ,
250
+ .PERM = > return error .PermissionDenied ,
251
251
else = > | err | return posix .unexpectedErrno (err ),
252
252
}
253
253
self .first_iter = false ;
@@ -267,7 +267,7 @@ pub const Iterator = switch (native_os) {
267
267
.INVAL = > unreachable ,
268
268
.OVERFLOW = > unreachable ,
269
269
.ACCES = > return error .AccessDenied ,
270
- .PERM = > return error .AccessDenied ,
270
+ .PERM = > return error .PermissionDenied ,
271
271
else = > | err | return posix .unexpectedErrno (err ),
272
272
}
273
273
}
@@ -294,7 +294,7 @@ pub const Iterator = switch (native_os) {
294
294
.BADF = > unreachable , // Dir is invalid
295
295
.NOMEM = > return error .SystemResources ,
296
296
.ACCES = > return error .AccessDenied ,
297
- .PERM = > return error .AccessDenied ,
297
+ .PERM = > return error .PermissionDenied ,
298
298
.FAULT = > unreachable ,
299
299
.NAMETOOLONG = > unreachable ,
300
300
.LOOP = > unreachable ,
@@ -768,6 +768,7 @@ pub const OpenError = error{
768
768
FileNotFound ,
769
769
NotDir ,
770
770
AccessDenied ,
771
+ PermissionDenied ,
771
772
SymLinkLoop ,
772
773
ProcessFdQuotaExceeded ,
773
774
NameTooLong ,
@@ -1503,7 +1504,7 @@ pub fn openDirZ(self: Dir, sub_path_c: [*:0]const u8, args: OpenOptions) OpenErr
1503
1504
.NOENT = > return error .FileNotFound ,
1504
1505
.NOMEM = > return error .SystemResources ,
1505
1506
.NOTDIR = > return error .NotDir ,
1506
- .PERM = > return error .AccessDenied ,
1507
+ .PERM = > return error .PermissionDenied ,
1507
1508
.BUSY = > return error .DeviceBusy ,
1508
1509
else = > | err | return posix .unexpectedErrno (err ),
1509
1510
}
@@ -1652,9 +1653,9 @@ pub fn deleteFile(self: Dir, sub_path: []const u8) DeleteFileError!void {
1652
1653
pub fn deleteFileZ (self : Dir , sub_path_c : [* :0 ]const u8 ) DeleteFileError ! void {
1653
1654
posix .unlinkatZ (self .fd , sub_path_c , 0 ) catch | err | switch (err ) {
1654
1655
error .DirNotEmpty = > unreachable , // not passing AT.REMOVEDIR
1655
- error .AccessDenied = > | e | switch (native_os ) {
1656
- // non-Linux POSIX systems return EPERM when trying to delete a directory, so
1657
- // we need to handle that case specifically and translate the error
1656
+ error .AccessDenied , error . PermissionDenied = > | e | switch (native_os ) {
1657
+ // non-Linux POSIX systems return permission errors when trying to delete a
1658
+ // directory, so we need to handle that case specifically and translate the error
1658
1659
.macos , .ios , .freebsd , .netbsd , .dragonfly , .openbsd , .solaris , .illumos = > {
1659
1660
// Don't follow symlinks to match unlinkat (which acts on symlinks rather than follows them)
1660
1661
const fstat = posix .fstatatZ (self .fd , sub_path_c , posix .AT .SYMLINK_NOFOLLOW ) catch return e ;
@@ -1679,6 +1680,7 @@ pub const DeleteDirError = error{
1679
1680
DirNotEmpty ,
1680
1681
FileNotFound ,
1681
1682
AccessDenied ,
1683
+ PermissionDenied ,
1682
1684
FileBusy ,
1683
1685
FileSystem ,
1684
1686
SymLinkLoop ,
@@ -1991,6 +1993,7 @@ pub fn readFileAllocOptions(
1991
1993
1992
1994
pub const DeleteTreeError = error {
1993
1995
AccessDenied ,
1996
+ PermissionDenied ,
1994
1997
FileTooBig ,
1995
1998
SymLinkLoop ,
1996
1999
ProcessFdQuotaExceeded ,
@@ -2073,6 +2076,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2073
2076
},
2074
2077
2075
2078
error .AccessDenied ,
2079
+ error .PermissionDenied ,
2076
2080
error .SymLinkLoop ,
2077
2081
error .ProcessFdQuotaExceeded ,
2078
2082
error .NameTooLong ,
@@ -2112,6 +2116,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2112
2116
},
2113
2117
2114
2118
error .AccessDenied ,
2119
+ error .PermissionDenied ,
2115
2120
error .InvalidUtf8 ,
2116
2121
error .InvalidWtf8 ,
2117
2122
error .SymLinkLoop ,
@@ -2168,6 +2173,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2168
2173
},
2169
2174
2170
2175
error .AccessDenied ,
2176
+ error .PermissionDenied ,
2171
2177
error .SymLinkLoop ,
2172
2178
error .ProcessFdQuotaExceeded ,
2173
2179
error .NameTooLong ,
@@ -2197,6 +2203,7 @@ pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2197
2203
},
2198
2204
2199
2205
error .AccessDenied ,
2206
+ error .PermissionDenied ,
2200
2207
error .InvalidUtf8 ,
2201
2208
error .InvalidWtf8 ,
2202
2209
error .SymLinkLoop ,
@@ -2273,6 +2280,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
2273
2280
},
2274
2281
2275
2282
error .AccessDenied ,
2283
+ error .PermissionDenied ,
2276
2284
error .SymLinkLoop ,
2277
2285
error .ProcessFdQuotaExceeded ,
2278
2286
error .NameTooLong ,
@@ -2309,6 +2317,7 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint
2309
2317
},
2310
2318
2311
2319
error .AccessDenied ,
2320
+ error .PermissionDenied ,
2312
2321
error .InvalidUtf8 ,
2313
2322
error .InvalidWtf8 ,
2314
2323
error .SymLinkLoop ,
@@ -2371,6 +2380,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
2371
2380
},
2372
2381
2373
2382
error .AccessDenied ,
2383
+ error .PermissionDenied ,
2374
2384
error .SymLinkLoop ,
2375
2385
error .ProcessFdQuotaExceeded ,
2376
2386
error .NameTooLong ,
@@ -2397,6 +2407,7 @@ fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File
2397
2407
},
2398
2408
2399
2409
error .AccessDenied ,
2410
+ error .PermissionDenied ,
2400
2411
error .InvalidUtf8 ,
2401
2412
error .InvalidWtf8 ,
2402
2413
error .SymLinkLoop ,
@@ -2447,10 +2458,7 @@ pub const AccessError = posix.AccessError;
2447
2458
/// open it and handle the error for file not found.
2448
2459
pub fn access (self : Dir , sub_path : []const u8 , flags : File.OpenFlags ) AccessError ! void {
2449
2460
if (native_os == .windows ) {
2450
- const sub_path_w = windows .sliceToPrefixedFileW (self .fd , sub_path ) catch | err | switch (err ) {
2451
- error .AccessDenied = > return error .PermissionDenied ,
2452
- else = > | e | return e ,
2453
- };
2461
+ const sub_path_w = try windows .sliceToPrefixedFileW (self .fd , sub_path );
2454
2462
return self .accessW (sub_path_w .span ().ptr , flags );
2455
2463
}
2456
2464
const path_c = try posix .toPosixPath (sub_path );
@@ -2460,10 +2468,7 @@ pub fn access(self: Dir, sub_path: []const u8, flags: File.OpenFlags) AccessErro
2460
2468
/// Same as `access` except the path parameter is null-terminated.
2461
2469
pub fn accessZ (self : Dir , sub_path : [* :0 ]const u8 , flags : File.OpenFlags ) AccessError ! void {
2462
2470
if (native_os == .windows ) {
2463
- const sub_path_w = windows .cStrToPrefixedFileW (self .fd , sub_path ) catch | err | switch (err ) {
2464
- error .AccessDenied = > return error .PermissionDenied ,
2465
- else = > | e | return e ,
2466
- };
2471
+ const sub_path_w = try windows .cStrToPrefixedFileW (self .fd , sub_path );
2467
2472
return self .accessW (sub_path_w .span ().ptr , flags );
2468
2473
}
2469
2474
const os_mode = switch (flags .mode ) {
0 commit comments