PathData implements Comparable<PathData> { public File toFile() { if (!(fs instanceof LocalFileSystem)) { throw new IllegalArgumentException("Not a local path: " + path); } return ((LocalFileSystem)fs).pathToFile(path); } PathData(String pathString, Configuration conf);  PathData(URI localPath, Configuration conf); private  PathData(FileSystem fs, String pathString); private  PathData(FileSystem fs, String pathString, FileStatus stat); FileStatus refreshStatus(); PathData suffix(String extension); boolean parentExists(); boolean representsDirectory(); PathData[] getDirectoryContents(); RemoteIterator<PathData> getDirectoryContentsIterator(); PathData getPathDataForChild(PathData child); static PathData[] expandAsGlob(String pattern, Configuration conf); @Override String toString(); File toFile(); @Override int compareTo(PathData o); @Override boolean equals(Object o); @Override int hashCode(); final FileSystem fs; final Path path; public FileStatus stat; public boolean exists; }
@Test (timeout = 30000) public void testToFile() throws Exception { PathData item = new PathData(".", conf); assertEquals(new File(testDir.toString()), item.toFile()); item = new PathData("d1/f1", conf); assertEquals(new File(testDir + "/d1/f1"), item.toFile()); item = new PathData(testDir + "/d1/f1", conf); assertEquals(new File(testDir + "/d1/f1"), item.toFile()); }
@Test (timeout = 5000) public void testToFileRawWindowsPaths() throws Exception { assumeWindows(); String[] winPaths = { "n:\\", "N:\\", "N:\\foo", "N:\\foo\\bar", "N:/", "N:/foo", "N:/foo/bar" }; PathData item; for (String path : winPaths) { item = new PathData(path, conf); assertEquals(new File(path), item.toFile()); } item = new PathData("foo\\bar", conf); assertEquals(new File(testDir + "\\foo\\bar"), item.toFile()); }