Summary
Remove the verbiage in the specification of java.nio.file.Files.isHidden() which states that a folder on Windows cannot be hidden.
Problem
Currently a Windows folder can have its 'hidden' attribute set but Files.isHidden() will return 'false' for the folder.
Solution
Allow Files.isHidden() to reflect the value of the 'hidden' attribute.
Specification
Diff:
--- a/src/java.base/share/classes/java/nio/file/Files.java
+++ b/src/java.base/share/classes/java/nio/file/Files.java
@@ -1608,12 +1608,13 @@
}
/**
- * Tells whether or not a file is considered <em>hidden</em>. The exact
- * definition of hidden is platform or provider dependent. On UNIX for
- * example a file is considered to be hidden if its name begins with a
- * period character ('.'). On Windows a file is considered hidden if it
- * isn't a directory and the DOS {@link DosFileAttributes#isHidden hidden}
- * attribute is set.
+ * Tells whether or not a file is considered <em>hidden</em>.
+ *
+ * @apiNote
+ * The exact definition of hidden is platform or provider dependent. On UNIX
+ * for example a file is considered to be hidden if its name begins with a
+ * period character ('.'). On Windows a file is considered hidden if the DOS
+ * {@link DosFileAttributes#isHidden hidden} attribute is set.
Updated specification:
/**
* Tells whether or not a file is considered <em>hidden</em>.
*
* @apiNote
* The exact definition of hidden is platform or provider dependent. On UNIX
* for example a file is considered to be hidden if its name begins with a
* period character ('.'). On Windows a file is considered hidden if the DOS
* {@link DosFileAttributes#isHidden hidden} attribute is set.
*
* <p> Depending on the implementation this method may require to access
* the file system to determine if the file is considered hidden.
*
* @param path
* the path to the file to test
*
* @return {@code true} if the file is considered hidden
*
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, the {@link SecurityManager#checkRead(String) checkRead}
* method is invoked to check read access to the file.
*/
public static boolean isHidden(Path path) throws IOException {}
- csr of
-
JDK-8215467 Files.isHidden should return true for hidden directories on Windows
- Resolved