@Test public void testOctalFileMode644() { Set<PosixFilePermission> perms = createPermissionSet(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.GROUP_READ, PosixFilePermission.OTHERS_READ); Assert.assertEquals(0644, FilePermissionHelper.toOctalFileMode(perms)); }
public static int toOctalFileMode(Set<PosixFilePermission> permissions) { int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; break; case OWNER_EXECUTE: result |= OWNER_EXEC_FILEMODE; break; case GROUP_READ: result |= GROUP_READ_FILEMODE; break; case GROUP_WRITE: result |= GROUP_WRITE_FILEMODE; break; case GROUP_EXECUTE: result |= GROUP_EXEC_FILEMODE; break; case OTHERS_READ: result |= OTHERS_READ_FILEMODE; break; case OTHERS_WRITE: result |= OTHERS_WRITE_FILEMODE; break; case OTHERS_EXECUTE: result |= OTHERS_EXEC_FILEMODE; break; } } return result; }
FilePermissionHelper { public static int toOctalFileMode(Set<PosixFilePermission> permissions) { int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; break; case OWNER_EXECUTE: result |= OWNER_EXEC_FILEMODE; break; case GROUP_READ: result |= GROUP_READ_FILEMODE; break; case GROUP_WRITE: result |= GROUP_WRITE_FILEMODE; break; case GROUP_EXECUTE: result |= GROUP_EXEC_FILEMODE; break; case OTHERS_READ: result |= OTHERS_READ_FILEMODE; break; case OTHERS_WRITE: result |= OTHERS_WRITE_FILEMODE; break; case OTHERS_EXECUTE: result |= OTHERS_EXEC_FILEMODE; break; } } return result; } }
FilePermissionHelper { public static int toOctalFileMode(Set<PosixFilePermission> permissions) { int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; break; case OWNER_EXECUTE: result |= OWNER_EXEC_FILEMODE; break; case GROUP_READ: result |= GROUP_READ_FILEMODE; break; case GROUP_WRITE: result |= GROUP_WRITE_FILEMODE; break; case GROUP_EXECUTE: result |= GROUP_EXEC_FILEMODE; break; case OTHERS_READ: result |= OTHERS_READ_FILEMODE; break; case OTHERS_WRITE: result |= OTHERS_WRITE_FILEMODE; break; case OTHERS_EXECUTE: result |= OTHERS_EXEC_FILEMODE; break; } } return result; } private  FilePermissionHelper(); }
FilePermissionHelper { public static int toOctalFileMode(Set<PosixFilePermission> permissions) { int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; break; case OWNER_EXECUTE: result |= OWNER_EXEC_FILEMODE; break; case GROUP_READ: result |= GROUP_READ_FILEMODE; break; case GROUP_WRITE: result |= GROUP_WRITE_FILEMODE; break; case GROUP_EXECUTE: result |= GROUP_EXEC_FILEMODE; break; case OTHERS_READ: result |= OTHERS_READ_FILEMODE; break; case OTHERS_WRITE: result |= OTHERS_WRITE_FILEMODE; break; case OTHERS_EXECUTE: result |= OTHERS_EXEC_FILEMODE; break; } } return result; } private  FilePermissionHelper(); static int toOctalFileMode(Set<PosixFilePermission> permissions); }
FilePermissionHelper { public static int toOctalFileMode(Set<PosixFilePermission> permissions) { int result = 0; for (PosixFilePermission permissionBit : permissions) { switch (permissionBit) { case OWNER_READ: result |= OWNER_READ_FILEMODE; break; case OWNER_WRITE: result |= OWNER_WRITE_FILEMODE; break; case OWNER_EXECUTE: result |= OWNER_EXEC_FILEMODE; break; case GROUP_READ: result |= GROUP_READ_FILEMODE; break; case GROUP_WRITE: result |= GROUP_WRITE_FILEMODE; break; case GROUP_EXECUTE: result |= GROUP_EXEC_FILEMODE; break; case OTHERS_READ: result |= OTHERS_READ_FILEMODE; break; case OTHERS_WRITE: result |= OTHERS_WRITE_FILEMODE; break; case OTHERS_EXECUTE: result |= OTHERS_EXEC_FILEMODE; break; } } return result; } private  FilePermissionHelper(); static int toOctalFileMode(Set<PosixFilePermission> permissions);  }