PathMeta constructor

PathMeta(
  1. String location, {
  2. String pattern = r'**',
  3. List<String> excludes = const [],
  4. List<int> sizes = const [],
  5. List<DateTime> times = const [],
  6. Map<String, String> env = const {},
  7. bool verbose = false,
  8. bool cancelOnError = true,
  9. String os = '',
  10. StatTimeType statTimeType = StatTimeType.modified,
})

Implementation

PathMeta(
  String location, {
  this.pattern = r'**',
  this.excludes = const [],
  this.sizes = const [],
  this.times = const [],
  this.env = const {},
  this.verbose = false,
  this.cancelOnError = true,
  this.os = '',
  this.statTimeType = StatTimeType.modified,
}) : path = location {
  // env = {...Platform.environment, ...env}; // merage env
  if (verbose) {
    logger = CliVerboseLogger(ansi: CliAnsi(CliAnsi.isSupportAnsi));
  }

  if (os.isEmpty) os = Platform.operatingSystem;
  if (path.contains(varInputRegexp)) path = expandVar(path, map: env);
  if (path.contains(r'~')) path = expandTilde(path);
  if (pattern.contains(varInputRegexp)) {
    pattern = expandVar(pattern, map: env);
  }

  if (excludes.isNotEmpty) {
    var excl = excludes
        .map((e) => e.contains(varInputRegexp) ? expandVar(e, map: env) : e);
    excludes = excl.toList();
  }

  // if (path.startsWith(r'.')) path = expandDotPath(path);
  path = p.normalize(path);
  type = FileSystemEntity.typeSync(path);

  // print('location:$location, path:$path');
  Stream<FileSystemEntity>? fseStream_;
  if (type == FileSystemEntityType.directory) {
    fseStream_ = Glob(pattern).list(root: path);
  }
  if (type == FileSystemEntityType.file) {
    fseStream_ = Stream.value(File(path));
  }
  if (fseStream_ != null) {
    fseStream = fseStream_.cast<FileSystemEntity>().transform(
          EntityStreamTransformer(
            scEntity,
            scFilted,
            cancelOnError: cancelOnError,
            excludes: excludes,
            sizes: sizes,
            times: times,
          ),
        );
  }
}