@Test public void testIsFileOwner() throws Exception { String path = FileToolsTest.class.getResource("FileToolsTest.txt").getPath(); boolean isOwner = FileTools.isFileOwner(path); assertTrue(isOwner); if (!"root".equals(System.getProperty("user.name"))) { isOwner = FileTools.isFileOwner(File.separator); assertFalse(isOwner); } }
public static boolean isFileOwner(String path) { try { String programRunner = FileTools.whoAmI(); Path nPath = Paths.get(path); UserPrincipal owner = Files.getOwner(nPath); boolean isFileOwner = owner.getName().equals(programRunner); return isFileOwner; } catch (IOException ex) { Log.error("Can't figure out the file ownership"); return false; } }
FileTools { public static boolean isFileOwner(String path) { try { String programRunner = FileTools.whoAmI(); Path nPath = Paths.get(path); UserPrincipal owner = Files.getOwner(nPath); boolean isFileOwner = owner.getName().equals(programRunner); return isFileOwner; } catch (IOException ex) { Log.error("Can't figure out the file ownership"); return false; } } }
FileTools { public static boolean isFileOwner(String path) { try { String programRunner = FileTools.whoAmI(); Path nPath = Paths.get(path); UserPrincipal owner = Files.getOwner(nPath); boolean isFileOwner = owner.getName().equals(programRunner); return isFileOwner; } catch (IOException ex) { Log.error("Can't figure out the file ownership"); return false; } }  }
FileTools { public static boolean isFileOwner(String path) { try { String programRunner = FileTools.whoAmI(); Path nPath = Paths.get(path); UserPrincipal owner = Files.getOwner(nPath); boolean isFileOwner = owner.getName().equals(programRunner); return isFileOwner; } catch (IOException ex) { Log.error("Can't figure out the file ownership"); return false; } }  static String byte2HexString(byte[] b); static ReturnValue verifyFile(File file); static ReturnValue dirPathExistsAndWritable(File file); static ReturnValue dirPathExistsAndReadable(File file); static ReturnValue fileExistsAndReadable(File file); static ReturnValue fileExistsAndNotEmpty(File file); static File createTempDirectory(File parentDir); static File createDirectoryWithUniqueName(File parentDir, String prefix); static File createFileWithUniqueName(File parentDir, String prefix); static boolean deleteDirectoryRecursive(File path); static boolean zipDirectoryRecursive(File path, File zipFileName, boolean compress); static boolean unzipFile(File path, File outputDir); static void listFilesRecursive(File path, List<File> filesArray); static Map<String, String> getKeyValueFromFile(String path); static boolean isFileOwner(String path); static String whoAmI(); static String getFilename(String filePath); static String getFilePath(String filePath); static LocalhostPair getLocalhost(OptionSet options); }
FileTools { public static boolean isFileOwner(String path) { try { String programRunner = FileTools.whoAmI(); Path nPath = Paths.get(path); UserPrincipal owner = Files.getOwner(nPath); boolean isFileOwner = owner.getName().equals(programRunner); return isFileOwner; } catch (IOException ex) { Log.error("Can't figure out the file ownership"); return false; } }  static String byte2HexString(byte[] b); static ReturnValue verifyFile(File file); static ReturnValue dirPathExistsAndWritable(File file); static ReturnValue dirPathExistsAndReadable(File file); static ReturnValue fileExistsAndReadable(File file); static ReturnValue fileExistsAndNotEmpty(File file); static File createTempDirectory(File parentDir); static File createDirectoryWithUniqueName(File parentDir, String prefix); static File createFileWithUniqueName(File parentDir, String prefix); static boolean deleteDirectoryRecursive(File path); static boolean zipDirectoryRecursive(File path, File zipFileName, boolean compress); static boolean unzipFile(File path, File outputDir); static void listFilesRecursive(File path, List<File> filesArray); static Map<String, String> getKeyValueFromFile(String path); static boolean isFileOwner(String path); static String whoAmI(); static String getFilename(String filePath); static String getFilePath(String filePath); static LocalhostPair getLocalhost(OptionSet options); static final String FORCE_HOST; }