include static method

List<String> include(
  1. List<String> files,
  2. String pattern, {
  3. void added(
    1. String path
    )?,
  4. bool? caseSensitive,
  5. void removed(
    1. String path
    )?,
})

Returns a list of paths from which will be removed elements that do not match glob pattern.

Parameters: files List of file paths. pattern Pattern of glob filter. added Function that is called whenever an item is added. caseSensitive True, if the pattern is case sensitive; otherwise false. removed Function that is called whenever an item is removed.

Implementation

static List<String> include(List<String> files, String pattern,
    {void Function(String path)? added,
    bool? caseSensitive,
    void Function(String path)? removed}) {
  pattern = FilePath.expand(pattern);
  if (!pathos.isAbsolute(pattern)) {
    pattern = getcwd() + '/' + pattern;
  }

  final isDirectory = (String path) {
    return Directory(path).existsSync();
  };

  final filter = GlobFilter(pattern,
      caseSensitive: caseSensitive,
      isDirectory: isDirectory,
      isWindows: _isWindows);

  return filter.include(files, added: added, removed: removed);
}