Re: Java reporting incorrect directory permission under Windows XP?



howachen@xxxxxxxxx wrote:
John W. Kennedy 寫道:

howachen@xxxxxxxxx wrote:
For the following codes:
//---------------------------------
import java.io.File;

public class Test {

/**
* @param args
*/
public static void main(String[] args) {

File file = new File("c:\\temp");

System.out.println(file.canWrite());

}

}
//---------------------------------
It return true, even in the "security" tab, I removed all the users
(i.e. i can't click into the folder using the windows explorer)

why Java return true?
In Windows, marking a directory "read-only" means only that it cannot be
rmdir'd. Java canWrite==false on a directory means that you can't create
a file in the directory, which Windows won't stop you from doing.


in Windows XP (NTFS file system), when you remove all owners in the
security tab, it REALLY means you can't write to the directory, no just
can't rmdir'd

Silly Java is depending on what Windows tells it (always a mistake), using a Windows API that was documented as answering the question "can I write in this directory?", but which in fact reports only on the old ATTRIB bits. With NTFS you have to go and mess with another whole new set of API's to get an answer to the question. Because it involves a large design change, it's been tied up in Java Specification Request #203, also known as "NIO.2". Unfortunately, this is targeted for Java 7.0, so it won't be fixed soon.

--
John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
-- Charles Williams. "Taliessin through Logres: Prelude"
.



Relevant Pages

  • Re: Security - Permissions Configuration
    ... >permissions to principals and not only codebases with Java Policy Files. ... different philosophies to the implementation of security. ... being) .NET does not duplicate Windows Security. ... While privileges are associated with an account or windows ...
    (microsoft.public.dotnet.general)
  • Re: Geocities HELP!
    ... Delete the Temporary Internet Files folder- it may be corrupted. ... > the same problem as I had with IE. I've also donloaded the latest Java, ... Tons of peiople are having this problem with Windows ... >> Disable any third-party security programs to see if one of ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Java reporting incorrect directory permission under Windows XP?
    ... why Java return true? ... In Windows, marking a directory "read-only" means only that it cannot be ...
    (comp.lang.java.programmer)
  • Re: Java reporting incorrect directory permission under Windows XP?
    ... It return true, even in the "security" tab, I removed all the users ... In Windows, marking a directory "read-only" means only that it cannot be ...
    (comp.lang.java.programmer)
  • HELP. I have major problems with Java.
    ... Ever since downloading a security updated for Windows 2000 and MSIE, ... So since the problem was with java, I did a little research on this ...
    (microsoft.public.windows.inetexplorer.ie6.browser)