|
1 | 1 | /* |
2 | | - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -281,22 +281,7 @@ static void go() throws IOException { |
281 | 281 | assertTrue(link2dir.isDirectory()); |
282 | 282 | assertTrue(link2link2dir.isDirectory()); |
283 | 283 |
|
284 | | - // on Windows we test with the DOS hidden attribute set |
285 | | - if (System.getProperty("os.name").startsWith("Windows")) { |
286 | | - DosFileAttributeView view = Files |
287 | | - .getFileAttributeView(file.toPath(), DosFileAttributeView.class); |
288 | | - view.setHidden(true); |
289 | | - try { |
290 | | - assertTrue(file.isHidden()); |
291 | | - assertTrue(link2file.isHidden()); |
292 | | - assertTrue(link2link2file.isHidden()); |
293 | | - } finally { |
294 | | - view.setHidden(false); |
295 | | - } |
296 | | - assertFalse(file.isHidden()); |
297 | | - assertFalse(link2file.isHidden()); |
298 | | - assertFalse(link2link2file.isHidden()); |
299 | | - } |
| 284 | + testDOSHiddenAttributes(); |
300 | 285 |
|
301 | 286 | header("length"); |
302 | 287 |
|
@@ -362,6 +347,26 @@ static void go() throws IOException { |
362 | 347 | } |
363 | 348 | } |
364 | 349 |
|
| 350 | + static void testDOSHiddenAttributes() throws IOException { |
| 351 | + // on Windows we test with the DOS hidden attribute set |
| 352 | + if (System.getProperty("os.name").startsWith("Windows")) { |
| 353 | + header("testDOSHiddenAttributes"); |
| 354 | + DosFileAttributeView view = Files |
| 355 | + .getFileAttributeView(file.toPath(), DosFileAttributeView.class); |
| 356 | + view.setHidden(true); |
| 357 | + try { |
| 358 | + assertTrue(file.isHidden()); |
| 359 | + assertTrue(link2file.isHidden()); |
| 360 | + assertTrue(link2link2file.isHidden()); |
| 361 | + } finally { |
| 362 | + view.setHidden(false); |
| 363 | + } |
| 364 | + assertFalse(file.isHidden()); |
| 365 | + assertFalse(link2file.isHidden()); |
| 366 | + assertFalse(link2link2file.isHidden()); |
| 367 | + } |
| 368 | + } |
| 369 | + |
365 | 370 | public static void main(String[] args) throws IOException { |
366 | 371 | if (supportsSymLinks(top)) { |
367 | 372 | try { |
|
0 commit comments