@Test @UseDataProvider("intModeTestData") public void translatingToPosixPermissionsWorks(int intMode, String asString) { final Set<PosixFilePermission> expected = PosixFilePermissions.fromString(asString); assertThat(PosixModes.intModeToPosix(intMode)) .as("integer mode is correctly translated") .isEqualTo(expected); }
public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); static Set<PosixFilePermission> intModeToPosix(int intMode); }
PosixModes { public static Set<PosixFilePermission> intModeToPosix(int intMode) { if ((intMode & INT_MODE_MAX) != intMode) { throw new RuntimeException("Invalid intMode: " + intMode); } final Set<PosixFilePermission> set = EnumSet.noneOf(PosixFilePermission.class); for (int i = 0; i < PERMISSIONS_LENGTH; i++) { if ((intMode & 1) == 1) { set.add(PERMISSIONS[PERMISSIONS_LENGTH - i - 1]); } intMode >>= 1; } return set; } private  PosixModes(); static Set<PosixFilePermission> intModeToPosix(int intMode);  }