/*
finds all the files from the given path

@param {string} root file path
@callback {string} file paths. could be called multiple times
439292
function findAllWatchFiles(path, callback) {
  fs.stat(path, function(err, stats){
    if (err) {
      winston.error('[forewoman] Error retrieving stats for file: ' + path);
      winston.error(err.message);
    } else {
      if (stats.isDirectory()) {
        fs.readdir(path, function(err, fileNames) {
          if(err) {
            winston.error('[forewoman] Error reading path: ' + path);
	    winston.error(err.message);
          } else {
            fileNames.forEach(function(fileName) {
              findAllWatchFiles(path + '/' + fileName, callback);
            });
          }
        });
      } else {
        callback(path);
      }
    }
  });
}
591706
function files(path, ...matchers) {
	if ( matchers.length ) {
		return listFiles(path.replace(/\\/g, '/'), matchers);
	}

	let rs = [];
	if( isDirectoryExists(path) ) {
		let ls = fs.readdirSync(path);
		ls.forEach((file, index) => rs.push(path + "/" + file));
	}
	return rs;
}
672849
function(root, path) {
				if (path.indexOf(this.SEPARATOR) === 0) {
					root = this.rootNode;
					path = path.substring(1);
				} else {
					if (!root) {
						if (!this.currentDirectory) {
							/* no node to resolve the path in terms of */
							return null;
						}
						root = this.currentDirectory;
					}
				}
				var segments = path.substring(0, path.lastIndexOf(this.SEPARATOR)).split(this.SEPARATOR);
				var result = root;
				for (var i = 0; i < segments.length; i++) {
					if (segments[i].length > 0) {
						result = this.getChild(result, segments[i]);
						if (!result || !result.Directory) {
							/* non-existent directory */
							return null;
						}
					}
				}

				/*
				 * If the full path represents a directory then initiate the
				 * retrieval of its full node info and children.
				 */
				var lastSegment = path.substring(path.lastIndexOf(this.SEPARATOR) + 1);
				var child = this.getChild(result, lastSegment);
				if (child) {
					this._retrieveNode(child);
				}

				if (!result.Children) {
					this._retrieveNode(result);
				}
				return result;
			}
207065
function extractFolders( files ) {
    return files.data.files.map( function extractPath( file ) {
      return path.parse( file ).dir;
    }).filter( function extractUnique( path, index, array ) {
      return array.indexOf( path ) === index;
    });
  }
1113011
function findPath(path, directories) {
  var cwd = directories[0];

  if (!cwd) {
    return null;
  }

  return findup(path, {cwd: cwd}) || findPath(path, slice.call(directories, 1));
}
816005
private Collection<File> doListAllFiles(File rootDir,
                                            boolean includeDirectories) {
        Collection<File> result = new Stack<File>();
        File[] files = rootDir.listFiles();
        for (File f : files) {
            if (f.isDirectory()) {
                if (includeDirectories) {
                    result.add(f);
                }
                result.addAll(doListAllFiles(f, includeDirectories));
            } else if (f.isFile()) {
                result.add(f);
            }
        }
        return result;
    }
1014530
function findResource(name, filepath, extList) {
  var candidates = [name, path.join(name, 'index')];
  var baseName = path.basename(name);
  if (baseName && baseName !== '.' && baseName !== '..') {
    candidates.push(path.join(name, baseName));
  }
  var info = null;

  candidates.every(function(candidate) {
    info = fis.uri(candidate, filepath);

    for (var i = 0, len = extList.length; i < len && !info.file; i++) {
      info = fis.uri(candidate + extList[i], filepath);
    }

    if (info && info.file) {
      return false;
    }

    return true;
  });

  return info;
}
363230
public static ArrayList<File> find(File path, Boolean recursive) {
        ArrayList<File> files = new ArrayList<File>();
        find(files, path, recursive);
        return files;
    }
145752
function paths(dir) {
	var paths = [];

	try {
		fs.statSync(dir);
	}
	catch (e) {
		return e;
	}

	(function traverse(dir, stack) {
		stack.push(dir);
		fs.readdirSync(stack.join('/')).forEach(function(file) {
			var path = stack.concat([file]).join('/'),
				stat = fs.statSync(path);

			if (file[0] == '.' || file === 'vendor') {
				return;
			} else if (stat.isFile() && /\.js$/.test(file)) {
				paths.push(path);
			} else if (stat.isDirectory()) {
				paths.push(path);
				traverse(file, stack);
			}
		});
		stack.pop();
	})(dir || '.', []);

	return paths;
}
206447
function searchFile(name, dirList, callback) {
  if (typeof dirList === 'function') {
    callback = dirList;
    dirList = '';
  }

  if (dirList === undefined) {
    dirList = ''
  }

  if (!Array.isArray(dirList)) {
    dirList = [dirList];
  }

  var success = dirList.some(function(dir) {
    if (!dir) {
      return false;
    }
    try {
      /**
       * Don't try to optimise this to be async since any failures will be
       * passed back to the caller:
       */

      var data = fs.readFileSync(path.join(dir, name), 'utf8');

      callback(null, data);
      return true;
    } catch (e) {
      return false;
    }
  });

  if (!success) {
    return callback('Failed to find file \'' + name + '\' at specified locations:' + dirList.join(','));
  }
}
919074
function allJasmineJsFiles(rootDir) {
  var files = [];
  fs.readdirSync(rootDir).filter(function(filename) {

    var fullPath = rootDir + "/" + filename;
    if (fs.statSync(fullPath).isDirectory() && !fullPath.match(/pages/)) {
      var subDirFiles = allJasmineJsFiles(fullPath);
      if (subDirFiles.length > 0) {
        files = files.concat();
        return true;
      }
    } else {
      if (fullPath.match(/\.js$/) && !isExcluded(fullPath)) {
        files.push(fullPath);
        return true;
      }
    }
    return false;
  });

  return files;
}
1242343
private static function findRootDir($path, array $roots)
    {
        foreach ($roots as $root) {
            if (0 === strpos($path, $root)) {
                return $root;
            }
        }
    }
677663
public final synchronized void findFiles(File directory, FileFilter filter, Collection<? super File> fileOut) {
		if (directory != null && filter != null) {
			File candidate;
			final List<File> candidates = new ArrayList<>();

			final String relativePath = removePathPrefix(getBaseDirectory(), directory);

			getLog().debug("Retreiving " //$NON-NLS-1$
					+ filter.toString() + " files from " //$NON-NLS-1$
					+ relativePath);

			candidates.add(directory);
			int nbFiles = 0;

			while (!candidates.isEmpty()) {
				candidate = candidates.remove(0);
				if (candidate.isDirectory()) {
					final File[] children = candidate.listFiles(filter);
					if (children != null) {
						for (final File child : children) {
							if (child != null && child.isDirectory()) {
								candidates.add(child);
							} else {
								fileOut.add(child);
								++nbFiles;
							}
						}
					}
				}
			}

			getLog().debug("Found " //$NON-NLS-1$
					+ nbFiles + " file(s)"); //$NON-NLS-1$
		}
	}
1189177
public static List<File> getDirectories(File root) {
        if (root == null)
            return Collections.emptyList();

        FileFilter filter = new DirsOnlyFilter();

        File fileList[] = root.listFiles(filter);

        if (fileList == null)
            return Collections.emptyList();
        else
            return Arrays.asList(fileList);
    }
305823
private static Set<File> findAllFiles(File dir) {
        Set<File> foundFiles = new HashSet<>();
        if (dir == null) {
            return foundFiles;
        }
        recurse(dir, foundFiles);
        return foundFiles;
    }
801673
def find_files_for_use(self, all_files):
        
        for path in all_files:
            # Find the path relative to the parent dir
            relpath = self.relpath_for(path)

            # Don't care about the ./
            if relpath.startswith("./"):
                relpath = relpath[2:]

            # Only care about paths that aren't filtered
            if not self.is_filtered(relpath):
                yield Path(path, relpath)
1235015
function(root, dirs, fn) {

    if(dirs.length > 0) {

        var dir = NX.Path.normalize(root + '/' + dirs.join('/') + '/');
        var file = dir + 'extent.action.js';

        NX.Path.exists(file, function(exists) {

            if(!exists) {
                dirs.pop();
                checkExtentActionFile(root, dirs, fn);
            } else {
                fn({
                    type: 'extent',
                    path: file
                });
            }

        });

    } else {
        fn();
    }

}