Override the implementation of scanDir, to look for additional files based upon any
specified source extensions
11576
protected void scanDir(File srcDir, File destDir, String[] files, String ext)
	{
		// If no source path was specified, we effectively created one by adding the generation
		// path.   Because of this, we need to be sure and add all source dirs to the path too.
		if (!_hasSourcepath)
		{
			Path srcPath = new Path(getProject());
			srcPath.setLocation(srcDir);
			setSourcepath(srcPath);
		}

		GlobPatternMapper m = new GlobPatternMapper();
		m.setFrom(ext);
		m.setTo("*.class");
		SourceFileScanner sfs = new SourceFileScanner(this);
		if (ext.equals("*.java"))
		{
			File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m);
			if (newFiles.length > 0)
			{
				File[] newCompileList = new File[compileList.length + newFiles.length];
				System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
				System.arraycopy(newFiles, 0, newCompileList, compileList.length,
						newFiles.length);
				compileList = newCompileList;
			}
		}
		else
		{
			String [] newSources = sfs.restrict(files, srcDir, destDir, m);
			int extLen = ext.length() - 1;  // strip wildcard
			if (newSources.length > 0)
			{
				File[] newCompileList = new File[compileList.length + newSources.length];
				System.arraycopy(compileList, 0, newCompileList, 0, compileList.length);
				try
				{
					FileUtils fileUtils = FileUtils.newFileUtils();
					for (int j = 0; j < newSources.length; j++)
					{
						String toName =
								newSources[j].substring(0, newSources[j].length() - extLen) +
										".java";

						File srcFile = new File(srcDir, newSources[j]);
						File dstFile = new File(_genDir, toName);
						fileUtils.copyFile(srcFile, dstFile, null, true, true);
						newCompileList[compileList.length + j] = dstFile;
					}
				}
				catch (IOException ioe)
				{
					throw new BuildException("Unable to copy " + ext + " file", ioe,
							getLocation());
				}
				compileList = newCompileList;
			}
		}
	}
728559
private String[] scanIncludedFiles() {
		final DirectoryScanner scanner = new DirectoryScanner();
		scanner.setBasedir(sourceDirectory);
		scanner.setIncludes(new String[]{inputFilename});
		scanner.scan();
		return scanner.getIncludedFiles();
	}
1062241
private List<String> scanFileSet(File sourceDirectory, FileSet fileSet) {
        final String[] emptyStringArray = {};

        DirectoryScanner scanner = new DirectoryScanner();

        scanner.setBasedir(sourceDirectory);
        if (fileSet.getIncludes() != null && !fileSet.getIncludes().isEmpty()) {
            scanner.setIncludes(fileSet.getIncludes().toArray(emptyStringArray));
        } else {
            scanner.setIncludes(DEFAULT_INCLUDES);
        }

        if (fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty()) {
            scanner.setExcludes(fileSet.getExcludes().toArray(emptyStringArray));
        }

        if (fileSet.isUseDefaultExcludes()) {
            scanner.addDefaultExcludes();
        }

        scanner.scan();

        return Arrays.asList(scanner.getIncludedFiles());
    }
1280924
def list_files(path, extension=".cpp", exclude="S.cpp"):
    """"""
    return ["%s/%s" % (path, f) for f in listdir(path) if f.endswith(extension) and (not f.endswith(exclude))]
1353805
private void scanExtensions(List<T> factories, String extensionsDir) {
    LOG.info("Loading extension jars from {}", extensionsDir);
    scan(Arrays.asList(ExtensionUtils.listExtensions(extensionsDir)), factories);
  }
774746
def _scan_file(filename, sentinel, source_type='import'):
    '''
    '''
    filename = os.path.abspath(filename)
    real_filename = os.path.realpath(filename)

    if os.path.getsize(filename) <= max_file_size:
        if real_filename not in sentinel and os.path.isfile(filename):
            sentinel.add(real_filename)

            basename = os.path.basename(filename)
            scope, imports = ast_scan_file(filename)

            if scope is not None and imports is not None:
                for imp in imports:
                    yield (source_type, imp.module, None)

                if 'INSTALLED_APPS' in scope and basename == 'settings.py':
                    log.info('Found Django settings: %s', filename)
                    for item in django.handle_django_settings(filename):
                        yield item
            else:
                log.warn('Could not scan imports from: %s', filename)
    else:
        log.warn('File size too large: %s', filename)
164324
public String[] getDirectoryContent(String scannerBaseDir, String[] includes, String[] excludes, boolean followSymlinks, boolean globCaseSensitive) {
        return getDirectoryContent(scannerBaseDir, includes, excludes, followSymlinks, globCaseSensitive, false);
    }
1293585
protected void scanDir(File srcDir, File destDir, String[] files) {
    GlobPatternMapper m = new GlobPatternMapper();
    SourceFileScanner sfs = new SourceFileScanner(this);
    List<File> newFiles;
    if(!isForce()) {
      log.warn("Relying on ant's SourceFileScanner, which only looks at timestamps.  If broken references result, try setting option 'force' to true.");
    }
    for (String extension : getScriptExtensions()) {
      m.setFrom("*." + extension);
      m.setTo("*.class");
      log.debug("Scanning for *." + extension + " files...");
      if(isForce()) {
        newFiles = asFiles(srcDir, files, m);
      } else {
        newFiles = Arrays.asList(sfs.restrictAsFiles(files, srcDir, destDir, m));
      }
      log.debug("Found these files:");
      for(File newFile : newFiles) {
        log.debug('\t' + newFile.getAbsolutePath());
      }
      compileList.addAll(newFiles);
    }

  }
260555
def scandir_limited(top, limit, deep=0):
    
    deep += 1
    try:
        scandir_it = Path2(top).scandir()
    except PermissionError as err:
        log.error("scandir error: %s" % err)
        return

    for entry in scandir_it:
        if entry.is_dir(follow_symlinks=False):
            if deep < limit:
                yield from scandir_limited(entry.path, limit, deep)
            else:
                yield entry
855681
function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) {
        if (!onlyRecordFailures) {
            // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
            var directory = ts.getDirectoryPath(candidate);
            if (directory) {
                onlyRecordFailures = !directoryProbablyExists(directory, state.host);
            }
        }
        return ts.forEach(extensions, function (ext) {
            return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state);
        });
    }
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();
            });
        }
    }
667387
public function scanExtensions() {
		$extensions = RtCache::get('loader@extensions');
		if (is_array($extensions)) {
			return $extensions;
		}
		if (is_dir(EXTENSIONS_PATH)) {
			$it         = new \DirectoryIterator (EXTENSIONS_PATH);
			$extensions = [];
			foreach ($it as $dir) {
				if ($dir->isDot()) {
					continue;
				}
				if ($dir->isDir()) {
					$dirname = $dir->getFilename();
					$boot    = EXTENSIONS_PATH . $dirname . DS . $dirname . '.php';
					if (is_file($boot)) {
						$extensions[ $dirname ] = $boot;
					}
					$this->scanSubDir($dir->getRealPath(), $extensions, $dirname);
				}
			}
			RtCache::add('loader@extensions', $extensions);
		} else {
			$extensions = [];
		}

		return $extensions;
	}
758980
def find_source_files(input_path, excludes):
    

    java_files = []

    input_path = os.path.normpath(os.path.abspath(input_path))

    for dirpath, dirnames, filenames in os.walk(input_path):
        if is_excluded(dirpath, excludes):
            del dirnames[:]
            continue

        for filename in filenames:
            if filename.endswith(".java"):
                java_files.append(os.path.join(dirpath, filename))

    return java_files
992610
function (dirs, done) {
    var self = this;
    utils.findExtensions(dirs, function (err, extensions) {
      if (err) return done(err);

      for (var i = 0; i < extensions.length; i++) {
        extensions[i].type = extensions[i].type || 'basic';
        extensions[i].id = extensions[i].id.toLowerCase();
        if (RESERVED.indexOf(extensions[i].id) !== -1) {
          return done(new Error('Extension id "' + extensions[i].id + '" is reserved. Your plugins are misconfigured.'));
        }
        if (self.ids[extensions[i].id]) {
          // XXX should we die hard, ignore, or warn?
          return done(new Error('Duplicate extension id! Your plugins are misconfigured.'));
        }
        self.ids[extensions[i].id] = true;
        self.extensions[extensions[i].type][extensions[i].id] = extensions[i];
      }
      done();
    });
  }
437574
def glob_by_extensions(directory, extensions):
    
    directorycheck(directory)
    files = []
    xt = files.extend
    for ex in extensions:
        xt(glob.glob('{0}/*.{1}'.format(directory, ex)))
    return files
819508
def filter_files(files, path, path_without_extension, template_extensions)
      results = []

      files.each do |file|
        match = if file.start_with?(path)
                  path
                else
                  path_without_extension
                end

        processable_extensions = file[(match.length + 1)..-1].split(".")

        # All processable_extensions must be processable
        # by a template_extension
        next unless (processable_extensions - template_extensions).empty?

        if file.start_with?(path)
          # The whole path is found in the filename, not just
          # the path without the extension.
          # it must have priority over all else
          results.unshift(file)
        else
          results.push(file)
        end
      end
      results
    end
1058162
async function _filesInDirectory(dirPath, options) {
  const basedir = options.basedir || getCallingDir();
  const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
  let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));

  try {
    const files = (await readDir(resolvedDirPath));
    if (options.rescursive) {
      const dirs = chain(await Promise.all(chain(files)
        .map(fileName=>path.resolve(resolvedDirPath, fileName))
        .map(async (file)=>{
          const stat = await lstat(file);
          if (stat.isDirectory()) return file;
        })
        .value())).filter(file=>file);
      if (dirs.value().length) files.push(...(await Promise.all(
        dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value()
      )));
    }
    return chain(files)
      .flattenDeep()
      .filter(fileName=>xExt.test(fileName))
      .map(fileName=>path.resolve(resolvedDirPath, fileName))
      .value();
  } catch (err) {
    return [];
  }
}