Should Files.createDirectory allow setting of group and other permissions?
Alan Bateman
Alan.Bateman at oracle.com
Fri Aug 5 05:40:44 PDT 2011
Tim Fox wrote:
> I am calling Files.createDirectory() to create a new directory with a
> set of Posix file permissions, on Linux. Here is some example code:
>
> String perms = "rwxrwxrwx";
> String dirName = "some-dir";
> FileAttribute<?> attrs =
> PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString(perms));
>
> Files.createDirectory(Paths.get(dirName), attrs);
> System.out.println(PosixFilePermissions.toString(Files.getPosixFilePermissions(Paths.get(dirName))));
>
>
> Prints out "rwxr-xr-x", not "rwxrwxrwx"
>
> If I change perms to "r-xrwxrwx" then it prints out "r-xr-xr-x"
>
> I.e. it seems when creating dirs the group and other permissions are
> ignored, and only the specified user permissions are set.
>
> Can anyone clarify whether this is expected behaviour?
>
> Thanks
What is your umask settings?
-Alan.
More information about the nio-discuss
mailing list