PDA

View Full Version : Windows file permission : isReadable()



demifred
4th October 2006, 10:52
Hello!

I'm unsing QT Jambi to test read permissions on files and directory from a Java application :


if (fileToRead.isDirectory()) {
QDir qDir = new QDir(fileToRead.getAbsolutePath());
System.out.println("Directory " + qDir.isReadable() + "--> " + fileToRead.getAbsolutePath());
} else {
QFileInfo qFileInfo = new QFileInfo(fileToRead.getAbsolutePath());
System.out.println("File --> " + qFileInfo.isReadable() + "--> " + fileToRead.getAbsolutePath());
}

The isReadable() method return allways true, even if the file or the directory is read protected ...

Can anybody help me ...?

Thanks! ;)

Fred

gfunk
4th October 2006, 18:11
I don't know anything about Qt Jambi, but on Windows, the read-only file attribute usually still allows you to read the file; you just can't write to it. Perhaps you want isWriteable()?

demifred
5th October 2006, 13:02
Hello!

My idea is not to test the general read-only file attribute.

I'm parsing all the files on a file system and I want to know if a file is read-protected for the current user or not... :confused:

Any idea ?