*/
private static List<String> scanPathDepthFirst(String path, boolean includeFiles, boolean includeDirectories, ScanHiddenMode hiddenMode,
ScanSortMode sortMode, ScanFailMode failMode, List<ScanErrorEntry> collectedScanErrors)
throws Exception
{
val result = new ArrayList<String>(64);
// maintain a stack of scanned files/directories
LinkedList<String> fsEntryStack = new LinkedList<String>();
fsEntryStack.addFirst(path);
// While there are directories to process
while (fsEntryStack.size() > 0)
{
String fsEntryName = fsEntryStack.removeFirst();
try
{
File currDir = new File(fsEntryName);
if (currDir.exists() && currDir.isDirectory())
{
// files to process
if (includeFiles)
{
// get files
File[] fis = filterIn(currDir.listFiles(), new HashSet<FileAttribute>(Arrays.asList(new FileAttribute[] {FileAttribute.File})));
fis = hideScanned(fis, hiddenMode, failMode, collectedScanErrors);
List<String> dirFiles = new ArrayList<String>(64);
for (File fi : fis)
dirFiles.add(fi.getAbsolutePath());
// sort
dirFiles = sortScanned(dirFiles, sortMode);
// next files to process
for (int i = dirFiles.size() - 1; i >= 0; i--)
fsEntryStack.addFirst(dirFiles.get(i));
}
// check if we need to include directories in results
if (includeDirectories)
result.addAll(Linq.toList(Linq.select(hideScanned(new File[] {currDir}, hiddenMode, failMode, collectedScanErrors),
getAbsolutePath())));
File[] dis = filterIn(currDir.listFiles(),
new HashSet<FileAttribute>(Arrays.asList(new FileAttribute[] {FileAttribute.Directory})));
dis = hideScanned(dis, hiddenMode, failMode, collectedScanErrors);
List<String> dirDirs = new ArrayList<String>(64);
for (File dirDir : dis)
dirDirs.add(dirDir.getAbsolutePath());
// sort
dirDirs = sortScanned(dirDirs, sortMode);
// next directories to process
for (int i = dirDirs.size() - 1; i >= 0; i--)
fsEntryStack.addFirst(dirDirs.get(i));
} else if (currDir.exists() && currDir.isFile())
{
File currFile = currDir;
// check if we need to include files in results
if (includeFiles)
result.addAll(Linq.toList(Linq.select(hideScanned(new File[] {currFile}, hiddenMode, failMode, collectedScanErrors),
getAbsolutePath())));
}
}
catch(Exception e)
{