[13] 8215467: Files.isHidden should return true for hidden directories on Windows
Brent Christian
brent.christian at oracle.com
Thu Jan 17 23:02:38 UTC 2019
Hi, Brian
The impl changes looks good to me.
In the CSR, I think the 'Solution' wording can be simplified to
something like
"Allow File.isHidden() to reflect the value of the 'hidden' attribute."
or
"File.isHidden() should reflect the value of the 'hidden' attribute."
but otherwise that looks good, too.
-Brent
On 1/17/19 12:58 PM, Brian Burkhalter wrote:
> https://bugs.openjdk.java.net/browse/JDK-8215467
>
> For Windows folders the read-only attribute is meaningless but the
> hidden attribute has meaning. With a folder's read-only attribute set,
> it is possible to create and append to a file within that folder. This
> appears to be the case whether the read-only attribute is set on the
> folder either before or after the contained file is created and written
> to. The hidden attribute does appear to be meaningful as, unless
> explicitly configured to display hidden folders, Windows Explorer does
> not display them if the hidden attribute is set.
>
> A change to the verbiage of the java.nio.file.Files.isHidden()
> specification is also called for. A CSR for this is [1] which includes a
> description of the proposed update. The implementation update is
> included below [2].
>
> Thanks,
>
> Brian
>
> [1] CSR: https://bugs.openjdk.java.net/browse/JDK-8217168 (also in need
> of review)
> [2] Implementation diff:
>
> ---
> a/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
> +++
> b/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
> @@ -1,11 +1,11 @@
> /*
> - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights
> reserved.
> + * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights
> reserved.
> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> *
>
> @@ -464,21 +464,18 @@
> public boolean isHidden(Path obj) throws IOException {
> WindowsPath file = WindowsPath.toWindowsPath(obj);
> file.checkRead();
> WindowsFileAttributes attrs = null;
> try {
> attrs = WindowsFileAttributes.get(file, true);
> } catch (WindowsException x) {
> x.rethrowAsIOException(file);
> }
> - // DOS hidden attribute not meaningful when set on directories
> - if (attrs.isDirectory())
> - return false;
> return attrs.isHidden();
> }
>
More information about the nio-dev
mailing list