Function for getting list of folders in directory
@param  {String} basePath the path the folder to get a list of containing folders
@return {Array}           array of folder names inside of basePath
323444
function getDirectories (basePath, includeFiles, userSuppliedFilterFn) {

  var items;
  try {
    items = fs.readdirSync(basePath);
  }
  catch (err) {

    // probably a file not a dir, but let's check error message to be sure
    if (includeFiles && String(err.stack).match(/ENOTDIR/)) {
      return [ basePath ];
    }

    // something is wrong, perhaps directory read permissions problem
    // maybe throw err instead
    console.error(err.stack);
    return [];
  }

  return items.filter(function (file) {

    var absPath = path.join(basePath, file);

    var stats = fs.lstatSync(absPath);
    if (stats.isSymbolicLink()) {
      return false;
    }

    var isDir = includeFiles ? true : stats.isDirectory();
    var isNotDotFile = path.basename(file).indexOf('.') !== 0;
    return isDir && isNotDotFile && (userSuppliedFilterFn || allOK)(absPath);

  })
  .map(function (item) {
    // return path.join(basePath, item);
    return item;
  })
  .sort();
}
102989
private File getBaseDir( File path)
    {
    return
      path == null?
      baseDir_ :
      
      path.isAbsolute()?
      path :

      new File( baseDir_, path.getPath());
    }
1191233
function getBasePath(base) {
	return new Promise((resolve, reject) => {
		if (base && typeof base.getPath === 'function') {
			const editorFile = base.getPath();
			if (!editorFile) {
				return reject(new Error('Unable to get base path: editor contains unsaved file'));
			}

			base = path.dirname(editorFile);
		}

		if (!base || typeof base !== 'string') {
			reject(new Error(`Unable to get base path from ${base}`));
		} else {
			resolve(base);
		}
	});
}
311727
function getTemplatesList(customPath = null) {
  const predefined = getDirectories(DEFAULT_PATH_TEMPLATES).reduce(createListOfDirectories, {})
  try {
    const custom = customPath ? getDirectories(customPath).reduce(createListOfDirectories, {}) : []

    return { ...predefined, ...custom }
  } catch (error) {
    Logger.warn('The custom templates path that you supply is unreachable')
    Logger.warn('falling back to defaults templates')
    return predefined
  }
}
1138936
function targetPath(fromPath, basePath, targetDirectory) {
  // console.log('targetPath:fromPath: ' + fromPath);
  // console.log('targetPath:basePath: ' + basePath);
  // console.log('targetPath:targetDirectory: ' + targetDirectory);
  var relativePath = path.relative(basePath, fromPath);
  // console.log('targetPath:relativePath: ' + relativePath);
  // console.log('targetPath: ' + path.resolve(targetDirectory, relativePath));
  return path.resolve(targetDirectory, relativePath);
}
138077
public static List<File> getDirectories(File path)
    {
        Check.notNull(path);

        return Optional.ofNullable(path.listFiles())
                       .map(files -> Arrays.asList(files)
                                           .stream()
                                           .filter(File::isDirectory)
                                           .collect(Collectors.toList()))
                       .orElseGet(Collections::emptyList);
    }
11644
function getFileList(branchName = config.baseBranch) {
  logger.debug(`getFileList(${branchName})`);
  return config.storage.getFileList(branchName);
}
868225
public function getBaseFolder( $path = null )
    {

        if ( $path ) {
            return sprintf( '%s/%s', $this->baseFolder, $path );
        }

        return $this->baseFolder;
    }
126952
function getAllFolders(dir, folderlist) {
    const files = fs.readdirSync(dir);
    folderlist = folderlist || [];
    files.forEach((file) => {
        if (fs.statSync(path.join(dir, file)).isDirectory()) {
            folderlist = getAllFolders(path.join(dir, file), folderlist);
            folderlist.push(path.join(dir, file));
        }
    });
    return folderlist;
}
1298851
function find_node_module_folder(basedir){
  var dirsep = basedir.split(path.sep);
  var result = [];

  var dirpart, dirname;

  for(var i = dirsep.length; i > 0; i--){
    if(dirsep[i-1] === 'node_modules') continue;

    dirpart = dirsep.slice(0, i);
    dirpart.push('node_modules');
    dirname = dirpart.join(path.sep);

    if(fs.existsSync(dirname) && fs.statSync(dirname).isDirectory()){
      result.push(dirname);
    }
  }

  return result;
}
788509
function getDirectories(source) {
  const isDirectory = sourcePath => lstatSync(sourcePath).isDirectory()
  return readdirSync(source)
    .map(name => join(source, name))
    .filter(isDirectory)
}
1001185
function getFiles(paths) {
  var result = fileUtil.getAllFiles(paths);

  var files = result.map(function (item) {
    return item.relativePath;
    // return path.join(item.basePath, item.relativePath);
  });

  return files;
}
905855
function findBowerMainFiles(componentsPath) {
        var files = [];

        fs.readdirSync(componentsPath).filter(function (file) {
            return fs.statSync(componentsPath + '/' + file).isDirectory();
        }).forEach(function (packageName) {
            var bowerJsonPath = componentsPath + '/' + packageName + '/bower.json';
            if (fs.existsSync(bowerJsonPath)) {
                var json = grunt.file.readJSON(bowerJsonPath);
                files.push(packageName + '/' + json.main);
            }
        });

        return files;
    }
159728
function basename (filePath) {
  if (isWindows) {
    // Windows executables must have an extension, so strip it away
    return path.basename(filePath, path.extname(filePath))
  }
  return path.basename(filePath)
}
672706
public static function within($listenerPath, $basePath)
    {
        return collect(static::getListenerEvents(
            (new Finder)->files()->in($listenerPath), $basePath
        ))->mapToDictionary(function ($event, $listener) {
            return [$event => $listener];
        })->all();
    }
954823
function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) {
                // Make all paths absolute/normalized if they are not already
                rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); });
                // Determine the path to the directory containing the script relative to the root directory it is contained within
                var relativeDirectory;
                for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) {
                    var rootDirectory = rootDirs_1[_i];
                    if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) {
                        relativeDirectory = scriptPath.substr(rootDirectory.length);
                        break;
                    }
                }
                // Now find a path for each potential directory that is to be merged with the one containing the script
                return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }));
            }
1247227
function scanFolders(rootFolderPath, folders, folderFileExtensions, callback) {
        var result = [];

        console.log('Scanning:: Folders', folders);
        console.log('Scanning:: Root folder path', rootFolderPath);
        var fileExtensions = self.fileExtensions.slice();
        scanFolder();

        function scanFolder() {
            var folder = folders.shift();
            if (folder === undefined) {
//                console.log('Scanning:: Finished with result', result);
                return callback(null, result);
            }
            if(folderFileExtensions.length){
                fileExtensions = folderFileExtensions.shift();
            }
            //var path = rootFolderPath + '/' + folder;
            var path = rootFolderPath + folder;

            console.log('Scanning:: Full path to folder', path, fileExtensions);

            fs.readdir(path, function (err, list) {
                if (err) {
                    console.error("Error scanning folder: ", path);
                    return scanFolder();
                }

                var files = [];

                for (var i = 0; i < list.length; i++) {
                    if (acceptFile(path, list[i], fileExtensions)) {
                        //files.push((folder.length ? folder + '/' : folder) + list[i]);
                        files.push(path + '/' + list[i]);
                    }
                }

                result = result.concat(files);

                scanFolder();
            });
        }
    }