FileUtil { public static Path[] stat2Paths(FileStatus[] stats) { if (stats == null) return null; Path[] ret = new Path[stats.length]; for (int i = 0; i < stats.length; ++i) { ret[i] = stats[i].getPath(); } return ret; }  static Path[] stat2Paths(FileStatus[] stats); static Path[] stat2Paths(FileStatus[] stats, Path path); static boolean fullyDelete(final File dir); static boolean fullyDelete(final File dir, boolean tryGrantPermissions); static String readLink(File f); static boolean fullyDeleteContents(final File dir); static boolean fullyDeleteContents(final File dir, final boolean tryGrantPermissions); @Deprecated static void fullyDelete(FileSystem fs, Path dir); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path[] srcs, 
                             FileSystem dstFS, Path dst,
                             boolean deleteSource, 
                             boolean overwrite, Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             FileSystem dstFS, Path dst, 
                             boolean deleteSource,
                             boolean overwrite,
                             Configuration conf); static boolean copy(FileSystem srcFS, FileStatus srcStatus,
                             FileSystem dstFS, Path dst,
                             boolean deleteSource,
                             boolean overwrite,
                             Configuration conf); static boolean copyMerge(FileSystem srcFS, Path srcDir, 
                                  FileSystem dstFS, Path dstFile, 
                                  boolean deleteSource,
                                  Configuration conf, String addString); static boolean copy(File src,
                             FileSystem dstFS, Path dst,
                             boolean deleteSource,
                             Configuration conf); static boolean copy(FileSystem srcFS, Path src, 
                             File dst, boolean deleteSource,
                             Configuration conf); static String makeShellPath(String filename); static String makeShellPath(File file); static String makeShellPath(File file, boolean makeCanonicalPath); static long getDU(File dir); static void unZip(File inFile, File unzipDir); static void unTar(File inFile, File untarDir); static int symLink(String target, String linkname); static int chmod(String filename, String perm
                          ); static int chmod(String filename, String perm, boolean recursive); static void setOwner(File file, String username,
      String groupname); static boolean setReadable(File f, boolean readable); static boolean setWritable(File f, boolean writable); static boolean setExecutable(File f, boolean executable); static boolean canRead(File f); static boolean canWrite(File f); static boolean canExecute(File f); static void setPermission(File f, FsPermission permission
                                   ); static final File createLocalTempFile(final File basefile,
                                               final String prefix,
                                               final boolean isDeleteOnExit); static void replaceFile(File src, File target); static File[] listFiles(File dir); static String[] list(File dir); static String[] createJarWithClassPath(String inputClassPath, Path pwd,
      Map<String, String> callerEnv); static String[] createJarWithClassPath(String inputClassPath, Path pwd,
      Path targetDir,
      Map<String, String> callerEnv); static final int SYMLINK_NO_PRIVILEGE; }
@Test (timeout = 30000) public void testStat2Paths1() { assertNull(FileUtil.stat2Paths(null)); FileStatus[] fileStatuses = new FileStatus[0]; Path[] paths = FileUtil.stat2Paths(fileStatuses); assertEquals(0, paths.length); Path path1 = new Path("file: Path path2 = new Path("file: fileStatuses = new FileStatus[] { new FileStatus(3, false, 0, 0, 0, path1), new FileStatus(3, false, 0, 0, 0, path2) }; paths = FileUtil.stat2Paths(fileStatuses); assertEquals(2, paths.length); assertEquals(paths[0], path1); assertEquals(paths[1], path2); }
@Test (timeout = 30000) public void testStat2Paths2() { Path defaultPath = new Path("file: Path[] paths = FileUtil.stat2Paths(null, defaultPath); assertEquals(1, paths.length); assertEquals(defaultPath, paths[0]); paths = FileUtil.stat2Paths(null, null); assertTrue(paths != null); assertEquals(1, paths.length); assertEquals(null, paths[0]); Path path1 = new Path("file: Path path2 = new Path("file: FileStatus[] fileStatuses = new FileStatus[] { new FileStatus(3, false, 0, 0, 0, path1), new FileStatus(3, false, 0, 0, 0, path2) }; paths = FileUtil.stat2Paths(fileStatuses, defaultPath); assertEquals(2, paths.length); assertEquals(paths[0], path1); assertEquals(paths[1], path2); }