FilePermissions Class — spring-boot Architecture
Architecture documentation for the FilePermissions class in FilePermissions.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/FilePermissions.java lines 34–87
public final class FilePermissions {
private FilePermissions() {
}
/**
* Return the integer representation of the file permissions for a path, where the
* integer value conforms to the
* <a href="https://en.wikipedia.org/wiki/Umask">umask</a> octal notation.
* @param path the file path
* @return the integer representation
* @throws IOException if path permissions cannot be read
*/
public static int umaskForPath(Path path) throws IOException {
Assert.notNull(path, "'path' must not be null");
PosixFileAttributeView attributeView = Files.getFileAttributeView(path, PosixFileAttributeView.class);
Assert.state(attributeView != null, "Unsupported file type for retrieving Posix attributes");
return posixPermissionsToUmask(attributeView.readAttributes().permissions());
}
/**
* Return the integer representation of a set of Posix file permissions, where the
* integer value conforms to the
* <a href="https://en.wikipedia.org/wiki/Umask">umask</a> octal notation.
* @param permissions the set of {@code PosixFilePermission}s
* @return the integer representation
*/
public static int posixPermissionsToUmask(Collection<PosixFilePermission> permissions) {
Assert.notNull(permissions, "'permissions' must not be null");
int owner = permissionToUmask(permissions, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_READ);
int group = permissionToUmask(permissions, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.GROUP_WRITE,
PosixFilePermission.GROUP_READ);
int other = permissionToUmask(permissions, PosixFilePermission.OTHERS_EXECUTE, PosixFilePermission.OTHERS_WRITE,
PosixFilePermission.OTHERS_READ);
return Integer.parseInt("" + owner + group + other, 8);
}
private static int permissionToUmask(Collection<PosixFilePermission> permissions, PosixFilePermission execute,
PosixFilePermission write, PosixFilePermission read) {
int value = 0;
if (permissions.contains(execute)) {
value += 1;
}
if (permissions.contains(write)) {
value += 2;
}
if (permissions.contains(read)) {
value += 4;
}
return value;
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free