path static method
A file (bytes + lookup of files next to it) or a directory, by what path is.
Implementation
static Future<FormatInput> path(String path) async {
final type = await FileSystemEntity.type(path, followLinks: false);
switch (type) {
case FileSystemEntityType.directory:
return FormatInput.directory(
_lookup(Directory(path)),
list: () => _list(Directory(path)),
);
case FileSystemEntityType.file:
return FormatInput.bytes(
await File(path).readAsBytes(),
siblings: _lookup(File(path).parent),
);
case FileSystemEntityType.link:
throw ValidationException('', '$path: symbolic link');
default:
throw NotFoundException('$path does not exist');
}
}