Package org.apache.tools.ant.util
Class PermissionUtils
java.lang.Object
org.apache.tools.ant.util.PermissionUtils
Contains helper methods for dealing with
PosixFilePermission or the traditional Unix mode representation of
permissions.- Since:
- Ant 1.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe supported types of files, maps to theisFoomethods inBasicFileAttributes. -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<PosixFilePermission>getPermissions(Resource r, Function<Path, Set<PosixFilePermission>> posixNotSupportedFallback) Sets permissions of aResource- returns an empty set for unsupported resource types or file systems that don't support PosixFilePermissions and no fallback has been provided..static intmodeFromPermissions(Set<PosixFilePermission> permissions, PermissionUtils.FileType type) Translates a set of permissions into a Unix stat(2)st_moderesult.static Set<PosixFilePermission>permissionsFromMode(int mode) Translates a Unix stat(2)st_modecompatible value into a set of permissions.static voidsetPermissions(Resource r, Set<PosixFilePermission> permissions, Consumer<Path> posixNotSupportedCallback) Sets permissions on aResource- doesn't do anything for unsupported resource types.
-
Method Details
-
modeFromPermissions
public static int modeFromPermissions(Set<PosixFilePermission> permissions, PermissionUtils.FileType type) Translates a set of permissions into a Unix stat(2)st_moderesult.- Parameters:
permissions- the permissionstype- the file type- Returns:
- the "mode"
-
permissionsFromMode
Translates a Unix stat(2)st_modecompatible value into a set of permissions.- Parameters:
mode- the "mode"- Returns:
- set of permissions
-
setPermissions
public static void setPermissions(Resource r, Set<PosixFilePermission> permissions, Consumer<Path> posixNotSupportedCallback) throws IOException Sets permissions on aResource- doesn't do anything for unsupported resource types.Supported types are:
- Parameters:
r- the resource to set permissions forpermissions- the permissionsposixNotSupportedCallback- optional callback that is invoked for a file provider resource if the file-system holding the file doesn't support PosixFilePermissions. The Path corresponding to the file is passed to the callback.- Throws:
IOException- if something goes wrong
-
getPermissions
public static Set<PosixFilePermission> getPermissions(Resource r, Function<Path, Set<PosixFilePermission>> posixNotSupportedFallback) throws IOExceptionSets permissions of aResource- returns an empty set for unsupported resource types or file systems that don't support PosixFilePermissions and no fallback has been provided..Supported types are:
- Parameters:
r- the resource to read permissions fromposixNotSupportedFallback- optional fallback function to provide permissions for file system that don't support PosixFilePermissions. The Path corresponding to the file is passed to the callback.- Returns:
- the permissions
- Throws:
IOException- if something goes wrong
-