stat method

  1. @override
Stat stat(
  1. String path,
  2. {EntityType type = EntityType.file}
)
override

Returns Stat for Entity.

Implementation

@override
Stat stat(
  String path, {
  EntityType type = EntityType.file,
}) {
  final nPath = join(root.path, path);
  if (type == EntityType.file) {
    io.FileStat stat = io.File(nPath).statSync();
    return FileStat(
      path: path,
      relativePath: nPath,
      type: type,
      size: stat.size,
      created: stat.modified,
      changed: stat.changed,
    );
  } else if (type == EntityType.dir) {
    io.FileStat stat = io.Directory(nPath).statSync();
    return DirStat(
      path: path,
      relativePath: nPath,
      type: type,
      size: stat.size,
      created: stat.modified,
      count: Future.sync(() async {
        int count = 0;
        await for (final entity in io.Directory(nPath).list(
          recursive: true,
        )) {
          if (entity is io.File) {
            count++;
          }
        }
        return count;
      }),
    );
  }
  throw "[Native filesystem] unsupported format!";
}