| ... | @@ -1415,3 +1415,22 @@ test "File.PermissionsUnix" { | ... | @@ -1415,3 +1415,22 @@ test "File.PermissionsUnix" { |
| 1415 | try testing.expect(permissions_unix.unixHas(.user, .execute)); | 1415 | try testing.expect(permissions_unix.unixHas(.user, .execute)); |
| 1416 | try testing.expect(!permissions_unix.unixHas(.other, .execute)); | 1416 | try testing.expect(!permissions_unix.unixHas(.other, .execute)); |
| 1417 | } | 1417 | } |
| | 1418 | |
| | 1419 | test "delete a read-only file on windows" { |
| | 1420 | if (builtin.os.tag != .windows) return error.SkipZigTest; |
| | 1421 | |
| | 1422 | var tmp = tmpDir(.{}); |
| | 1423 | defer tmp.cleanup(); |
| | 1424 | const file = try tmp.dir.createFile("test_file", .{ .read = true }); |
| | 1425 | // Create a file and make it read-only |
| | 1426 | const metadata = try file.metadata(); |
| | 1427 | var permissions = metadata.permissions(); |
| | 1428 | permissions.setReadOnly(true); |
| | 1429 | try file.setPermissions(permissions); |
| | 1430 | try testing.expectError(error.AccessDenied, tmp.dir.deleteFile("test_file")); |
| | 1431 | // Now make the file not read-only |
| | 1432 | permissions.setReadOnly(false); |
| | 1433 | try file.setPermissions(permissions); |
| | 1434 | file.close(); |
| | 1435 | try tmp.dir.deleteFile("test_file"); |
| | 1436 | } |