/// <exception cref="System.Exception"/> public virtual LocatedFileStatusFetcher.ProcessInputDirCallable.Result Call() { LocatedFileStatusFetcher.ProcessInputDirCallable.Result result = new LocatedFileStatusFetcher.ProcessInputDirCallable.Result (); result.fs = fs; if (fileStatus.IsDirectory()) { RemoteIterator <LocatedFileStatus> iter = fs.ListLocatedStatus(fileStatus.GetPath( )); while (iter.HasNext()) { LocatedFileStatus stat = iter.Next(); if (inputFilter.Accept(stat.GetPath())) { if (recursive && stat.IsDirectory()) { result.dirsNeedingRecursiveCalls.AddItem(stat); } else { result.locatedFileStatuses.AddItem(stat); } } } } else { result.locatedFileStatuses.AddItem(fileStatus); } return(result); }
/// <exception cref="System.IO.IOException"/> private IList <FileStatus> SingleThreadedListStatus(JobContext job, Path[] dirs, PathFilter inputFilter, bool recursive) { IList <FileStatus> result = new AList <FileStatus>(); IList <IOException> errors = new AList <IOException>(); for (int i = 0; i < dirs.Length; ++i) { Path p = dirs[i]; FileSystem fs = p.GetFileSystem(job.GetConfiguration()); FileStatus[] matches = fs.GlobStatus(p, inputFilter); if (matches == null) { errors.AddItem(new IOException("Input path does not exist: " + p)); } else { if (matches.Length == 0) { errors.AddItem(new IOException("Input Pattern " + p + " matches 0 files")); } else { foreach (FileStatus globStat in matches) { if (globStat.IsDirectory()) { RemoteIterator <LocatedFileStatus> iter = fs.ListLocatedStatus(globStat.GetPath()); while (iter.HasNext()) { LocatedFileStatus stat = iter.Next(); if (inputFilter.Accept(stat.GetPath())) { if (recursive && stat.IsDirectory()) { AddInputPathRecursively(result, fs, stat.GetPath(), inputFilter); } else { result.AddItem(stat); } } } } else { result.AddItem(globStat); } } } } } if (!errors.IsEmpty()) { throw new InvalidInputException(errors); } return(result); }
/// <summary>Add files in the input path recursively into the results.</summary> /// <param name="result">The List to store all files.</param> /// <param name="fs">The FileSystem.</param> /// <param name="path">The input path.</param> /// <param name="inputFilter">The input filter that can be used to filter files/dirs. /// </param> /// <exception cref="System.IO.IOException"/> protected internal virtual void AddInputPathRecursively(IList <FileStatus> result, FileSystem fs, Path path, PathFilter inputFilter) { RemoteIterator <LocatedFileStatus> iter = fs.ListLocatedStatus(path); while (iter.HasNext()) { LocatedFileStatus stat = iter.Next(); if (inputFilter.Accept(stat.GetPath())) { if (stat.IsDirectory()) { AddInputPathRecursively(result, fs, stat.GetPath(), inputFilter); } else { result.AddItem(stat); } } } }
public override bool IsDirectory() { return(myFs.IsDirectory()); }