GlobLister constructor

GlobLister(
  1. String pattern, {
  2. bool? caseSensitive,
  3. bool exists(
    1. String path
    )?,
  4. bool followLinks = true,
  5. bool isDirectory(
    1. String path
    )?,
  6. bool? isWindows,
  7. List<String> list(
    1. String path,
    2. bool? followLinks
    )?,
})

Creates the glob lister.

Parameters: pattern Pattern of this glob lister. caseSensitive True, if the pattern is case sensitive; otherwise false. exists Function that determines that the specified path exists or not. followLinks True, if lister should follow symbolic links; otherwise false. isDirectory Function that determines that the specified path is a directory or not. isWindows True, if used the path in the Windows style; otherwise false. list Function that lists the specified directory.

Implementation

GlobLister(this.pattern,
    {bool? caseSensitive,
    bool Function(String path)? exists,
    bool followLinks = true,
    bool Function(String path)? isDirectory,
    bool? isWindows,
    List<String> Function(String path, bool? followLinks)? list}) {
  if (exists == null) {
    throw ArgumentError.notNull('exists');
  }

  if (isDirectory == null) {
    throw ArgumentError.notNull('isDirectory');
  }

  if (isWindows == null) {
    throw ArgumentError.notNull('isWindows');
  }

  if (list == null) {
    throw ArgumentError.notNull('list');
  }

  if (caseSensitive == null) {
    if (isWindows) {
      caseSensitive = false;
    } else {
      caseSensitive = true;
    }
  }

  _caseSensitive = caseSensitive;
  _exists = exists;
  _followLinks = followLinks;
  _isDirectory = isDirectory;
  _isWindows = isWindows;
  _list = list;
  _glob = Glob(pattern, caseSensitive: caseSensitive);
  _segments = _glob.segments;
  if (_segments!.isNotEmpty) {
    _onlyDirectory = _segments!.last.onlyDirectory;
  } else {
    _onlyDirectory = false;
  }
}