Stat extends Shell { public Stat(Path path, long blockSize, boolean deref, FileSystem fs) throws IOException { super(0L, true); this.original = path; Path stripped = new Path( original.makeQualified(fs.getUri(), fs.getWorkingDirectory()) .toUri().getPath()); this.qualified = stripped.makeQualified(fs.getUri(), fs.getWorkingDirectory()); this.path = new Path(qualified.toUri().getPath()); this.blockSize = blockSize; this.dereference = deref; setEnvironment(Collections.singletonMap("LANG", "C")); } Stat(Path path, long blockSize, boolean deref, FileSystem fs); FileStatus getFileStatus(); static boolean isAvailable();  }
@Test(timeout=10000) public void testStat() throws Exception { Assume.assumeTrue(Stat.isAvailable()); FileSystem fs = FileSystem.getLocal(new Configuration()); Path testDir = new Path(getTestRootPath(fs), "teststat"); fs.mkdirs(testDir); Path sub1 = new Path(testDir, "sub1"); Path sub2 = new Path(testDir, "sub2"); fs.mkdirs(sub1); fs.createSymlink(sub1, sub2, false); FileStatus stat1 = new Stat(sub1, 4096l, false, fs).getFileStatus(); FileStatus stat2 = new Stat(sub2, 0, false, fs).getFileStatus(); assertTrue(stat1.isDirectory()); assertFalse(stat2.isDirectory()); fs.delete(testDir, true); }