6728842: File.setReadOnly does not make a directory read-only (win)
Alan Bateman
Alan.Bateman at oracle.com
Wed Sep 29 13:57:28 UTC 2010
I need a reviewer for a change to java.io.File's setReadOnly and
setWritable methods so that they don't change the DOS readonly attribute
on directories (or folders as Windows calls them). These methods have
never worked correctly for directories on Windows because the semantics
of this attribute is different for directories (it determines if the
directory can be deleted, not whether is is writable, and is used by
Windows Explorer to determine if the directory is special, sending it
off looking for a hidden Desktop.ini file). Early on in jdk7, the
canWrite method was changed to ignore the readonly attribute on
directories so changing the set* methods to ignore the attribute
restores the status quo. I should say that changing the implementation
has some risk. If it does cause problems they we may need to include a
compatibility switch. The alternative to ignoring the readonly attribute
is to insert a deny rule into the directory's DACL (when on NTFS) but
that has a lot of potential to cause problems for end-users. As part of
the change proposed here, the SetAccess test has been changed so that it
no longer execs "ls -l" and this fixes another bug (6464744) where the
test fails if the sticky bit is set. The webrev with the changes is here:
http://cr.openjdk.java.net/~alanb/6728842/webrev/
Thanks,
Alan.
More information about the core-libs-dev
mailing list