List of utility methods to do Posix
int | intFilePermissions(Set int File Permissions int r = 0; for (PosixFilePermission pfp : permissions) { switch (pfp) { case OTHERS_EXECUTE: r |= 1; break; case OTHERS_WRITE: r |= 2; ... |
int | mapValue(PosixFilePermission p) map Value switch (p) { case GROUP_EXECUTE: return 1 * 8; case GROUP_READ: return 4 * 8; case GROUP_WRITE: return 2 * 8; case OWNER_EXECUTE: ... |
Set | posixFilePermissions(int mode) posix File Permissions int mask = 1; Set<PosixFilePermission> perms = EnumSet.noneOf(PosixFilePermission.class); for (PosixFilePermission flag : decodeMap) { if (flag != null && (mask & mode) != 0) { perms.add(flag); mask = mask << 1; return perms; |
void | setPermissionsToFile(File f, Collection set Permissions To File boolean readable = perms != null && (perms.contains(PosixFilePermission.OWNER_READ) || perms.contains(PosixFilePermission.GROUP_READ) || perms.contains(PosixFilePermission.OTHERS_READ)); f.setReadable(readable, false); boolean writable = perms != null && (perms.contains(PosixFilePermission.OWNER_WRITE) || perms.contains(PosixFilePermission.GROUP_WRITE) || perms.contains(PosixFilePermission.OTHERS_WRITE)); f.setWritable(writable, false); ... |
int | toOctalFileMode(Set Converts a set of PosixFilePermission to chmod-style octal file mode. int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; ... |
int | toUnixFileMode(Set to Unix File Mode int mode = 0; if (perms.contains(PosixFilePermission.OWNER_READ)) mode |= 0400; if (perms.contains(PosixFilePermission.OWNER_WRITE)) mode |= 0200; if (perms.contains(PosixFilePermission.OWNER_EXECUTE)) mode |= 0100; if (perms.contains(PosixFilePermission.GROUP_READ)) ... |
Set | unixModeToPosixSet(int unixMode) unix Mode To Posix Set Set<PosixFilePermission> permissions = new TreeSet<PosixFilePermission>(); int bit = 8; while (bit >= 0) { if ((unixMode & (1 << bit)) != 0) { permissions.add(posixFilePermissionsBitSorted[bit]); } else { --bit; ... |