checkLeadsToFiletype function
Check that path
leads to a FileSystemEntity of type
.
Exits the program if path
does not lead to a
FileSystemEntity of type
.
Implementation
void checkLeadsToFiletype(String path, FileSystemEntityType type) {
final filetype = FileSystemEntity.typeSync(path);
if (filetype == type) return;
final message = switch (filetype) {
FileSystemEntityType.notFound =>
"Aborting because the path '$path' does not exist",
_ => "Aborting because the path '$path' does not lead to a $type "
"but to a $filetype."
};
printErr(message);
exit(1);
}