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,
}) {
  if (type == EntityType.file) {
    if (open(path) case VFile file) {
      return FileStat(
        path: path,
        type: type,
        size: file.data.length,
        created: file.created,
        changed: file.changed,
      );
    } else {
      throw "[Virtual filesystem] file not exists!";
    }
  } else if (type == EntityType.dir) {
    if (open(path) case VDir dir) {
      return DirStat(
        path: path,
        type: type,
        size: dir.size,
        created: dir.created,
        count: Future.value(dir.count),
      );
    } else {
      throw "[Virtual filesystem] dir not exists!";
    }
  }
  throw "[Virtual filesystem] unsupported format!";
}