open method

VEntity? open(
  1. String path,
  2. {EntityType type = EntityType.file}
)

Implementation

VEntity? open(
  String path, {
  EntityType type = EntityType.file,
}) {
  VEntity entity = root;

  for (final name in split(path)) {
    if (entity case VDir dir) {
      if (dir.children[name] != null) {
        entity = dir.children[name]!;
        continue;
      }
    }
    return null;
  }

  if (type == EntityType.file && entity is VFile ||
      type == EntityType.dir && entity is VDir) {
    return entity;
  }

  return null;
}