@Test public void changeLocalFilePermission() throws IOException { assumeFalse(System.getProperty("user.name").equals("root")); File tempFile = mTestFolder.newFile("perm.txt"); FileUtils.changeLocalFilePermission(tempFile.getAbsolutePath(), "---------"); assertFalse(tempFile.canRead() || tempFile.canWrite() || tempFile.canExecute()); FileUtils.changeLocalFilePermission(tempFile.getAbsolutePath(), "rwxrwxrwx"); assertTrue(tempFile.canRead() && tempFile.canWrite() && tempFile.canExecute()); FileUtils.changeLocalFilePermission(tempFile.getAbsolutePath(), "r--r--r--"); assertTrue(tempFile.canRead()); assertFalse(tempFile.canWrite()); assertFalse(tempFile.canExecute()); mException.expect(IOException.class); @SuppressWarnings({"unused", "resource"}) FileWriter fw = new FileWriter(tempFile); fail("opening a read-only file for writing should have failed"); }
public static void changeLocalFilePermission(String filePath, String perms) throws IOException { Files.setPosixFilePermissions(Paths.get(filePath), PosixFilePermissions.fromString(perms)); }
FileUtils { public static void changeLocalFilePermission(String filePath, String perms) throws IOException { Files.setPosixFilePermissions(Paths.get(filePath), PosixFilePermissions.fromString(perms)); } }
FileUtils { public static void changeLocalFilePermission(String filePath, String perms) throws IOException { Files.setPosixFilePermissions(Paths.get(filePath), PosixFilePermissions.fromString(perms)); } private  FileUtils(); }
FileUtils { public static void changeLocalFilePermission(String filePath, String perms) throws IOException { Files.setPosixFilePermissions(Paths.get(filePath), PosixFilePermissions.fromString(perms)); } private  FileUtils(); static void changeLocalFileGroup(String path, String group); static void changeLocalFilePermission(String filePath, String perms); static void changeLocalFileToFullPermission(String filePath); static String getLocalFileOwner(String filePath); static String getLocalFileGroup(String filePath); static short getLocalFileMode(String filePath); static short translatePosixPermissionToMode(Set<PosixFilePermission> permission); static void changeLocalFileUser(String path, String user); static void setLocalDirStickyBit(String dir); static void createBlockPath(String path, String workerDataFolderPermissions); static void move(String srcPath, String dstPath); static void delete(String path); static void deletePathRecursively(String path); static boolean createStorageDirPath(String path, String workerDataFolderPermissions); static void createFile(String filePath); static void createDir(String path); static boolean exists(String path); static boolean isStorageDirAccessible(String path); }
FileUtils { public static void changeLocalFilePermission(String filePath, String perms) throws IOException { Files.setPosixFilePermissions(Paths.get(filePath), PosixFilePermissions.fromString(perms)); } private  FileUtils(); static void changeLocalFileGroup(String path, String group); static void changeLocalFilePermission(String filePath, String perms); static void changeLocalFileToFullPermission(String filePath); static String getLocalFileOwner(String filePath); static String getLocalFileGroup(String filePath); static short getLocalFileMode(String filePath); static short translatePosixPermissionToMode(Set<PosixFilePermission> permission); static void changeLocalFileUser(String path, String user); static void setLocalDirStickyBit(String dir); static void createBlockPath(String path, String workerDataFolderPermissions); static void move(String srcPath, String dstPath); static void delete(String path); static void deletePathRecursively(String path); static boolean createStorageDirPath(String path, String workerDataFolderPermissions); static void createFile(String filePath); static void createDir(String path); static boolean exists(String path); static boolean isStorageDirAccessible(String path);  }