/** * Get a listing of all files in that match the file pattern <i>srcf</i>. * @param srcf a file pattern specifying source files * @param flags LS options. * @throws IOException * @see org.apache.hadoop.fs.FileSystem#globStatus(Path) */ private int ls(String srcf, EnumSet<LsOption> flags) throws IOException { Path srcPath = new Path(srcf); FileSystem srcFs = srcPath.getFileSystem(this.getConf()); FileStatus[] srcs = srcFs.globStatus(srcPath); if (srcs==null || srcs.length==0) { throw new FileNotFoundException("Cannot access " + srcf + ": No such file or directory."); } boolean printHeader = (srcs.length == 1) ? true: false; int numOfErrors = 0; for(int i=0; i<srcs.length; i++) { numOfErrors += ls(srcs[i], srcFs, flags, printHeader); } return numOfErrors == 0 ? 0 : -1; }
/** * Get a listing of all files in that match the file pattern <i>srcf</i>. * @param srcf a file pattern specifying source files * @param recursive if need to list files in subdirs * @throws IOException * @see org.apache.hadoop.fs.FileSystem#globStatus(Path) */ private int ls(String srcf, boolean recursive) throws IOException { Path srcPath = new Path(srcf); FileSystem srcFs = srcPath.getFileSystem(this.getConf()); FileStatus[] srcs = srcFs.globStatus(srcPath); if (srcs==null || srcs.length==0) { throw new FileNotFoundException("Cannot access " + srcf + ": No such file or directory."); } boolean printHeader = (srcs.length == 1) ? true: false; int numOfErrors = 0; for(int i=0; i<srcs.length; i++) { numOfErrors += ls(srcs[i].getPath(), srcFs, recursive, printHeader); } return numOfErrors == 0 ? 0 : -1; }
System.out.println(cur.toUri().getPath()); if (recursive && stat.isDir()) { numOfErrors += ls(cur,srcFs, recursive, printHeader);
System.out.println(cur.toUri().getPath()); if (recursive && stat.isDir()) { numOfErrors += ls(stat,srcFs, flags, printHeader);
new Count(argv, i, getConf()).runAll(); } else if ("-ls".equals(cmd)) { exitCode = ls(argv[i], EnumSet.noneOf(LsOption.class)); } else if ("-lsr".equals(cmd)) { exitCode = ls(argv[i], EnumSet.of(LsOption.Recursive)); } else if ("-lsrx".equals(cmd)) { exitCode = ls(argv[i], EnumSet.of(LsOption.Recursive, LsOption.WithBlockSize)); } else if ("-touchz".equals(cmd)) {
exitCode = doall(cmd, argv, i); } else { exitCode = ls(Path.CUR_DIR, EnumSet.noneOf(LsOption.class)); exitCode = doall(cmd, argv, i); } else { exitCode = ls(Path.CUR_DIR, EnumSet.of(LsOption.Recursive)); exitCode = doall(cmd, argv, i); } else { exitCode = ls(Path.CUR_DIR, EnumSet.of(LsOption.Recursive, LsOption.WithBlockSize));