0

I have been asked with this question, since I'm not a Windows user I could not answer it.

Would you please explain me why the following piece of code does not return correct results when is executed on Windows, while it returns precise results when is run on Linux.

But eventually on windows it raise an exception since OS does not let the program to create the folder.

we use JDK 6

We remove all permissions from a folder c:\temp

enter image description here

and we check the permissions in the program and all methods return true!!!

enter image description here

ehsun7b
  • 4,796
  • 14
  • 59
  • 98
  • 1
    Maybe it's because you're working with Access Control Lists (ACL) instead of POSIX files permissions... Don't know, just guessing. – Pedro Boechat Nov 28 '12 at 03:41
  • Is it true that we should use `checkAccess` method to get the permission details of a file (ACL) ? – ehsun7b Nov 28 '12 at 03:49
  • is this article explaining the same problem? http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420020 – ehsun7b Nov 28 '12 at 03:50
  • 1
    I guess this bug report is talking about that ("The problem is that access *ONLY* checks the file or directory's permissions. It knows nothing about system security."). Here's what I found at another Stackoverflow question: Java 7 NIO has a brand new way to query file attributes - permissions included -(http://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/package-frame.html). (SO Reference: http://stackoverflow.com/questions/1198517/manipulating-windows-file-permissions-in-java) – Pedro Boechat Nov 28 '12 at 03:56
  • Thanks, I'm already aware of the NIO in JDK 7, but looking for a workaround for JDK 6. – ehsun7b Nov 28 '12 at 07:57

0 Answers0