Re: Java reporting incorrect directory permission under Windows XP?
- From: "John W. Kennedy" <jwkenne@xxxxxxxxxxxxx>
- Date: Sun, 16 Jul 2006 23:27:35 -0400
howachen@xxxxxxxxx wrote:
John W. Kennedy 寫道:
howachen@xxxxxxxxx wrote:For the following codes:In Windows, marking a directory "read-only" means only that it cannot be
//---------------------------------
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?
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"
.
- References:
- Java reporting incorrect directory permission under Windows XP?
- From: howachen
- Re: Java reporting incorrect directory permission under Windows XP?
- From: John W. Kennedy
- Re: Java reporting incorrect directory permission under Windows XP?
- From: howachen
- Java reporting incorrect directory permission under Windows XP?
- Prev by Date: Oops, I mean < 30 Mb
- Next by Date: Re: sample jsp servlet application required
- Previous by thread: Re: Java reporting incorrect directory permission under Windows XP?
- Next by thread: sample jsp servlet application required
- Index(es):
Relevant Pages
|