assertPreviewPathIsFile function
- @visibleForTesting
- String resolvedFilePath, {
- FileSystemEntityType resolveEntityType(
- String path
Throws when resolvedFilePath does not refer to a readable file.
Implementation
@visibleForTesting
void assertPreviewPathIsFile(
String resolvedFilePath, {
FileSystemEntityType Function(String path)? resolveEntityType,
}) {
final entityType = (resolveEntityType ??
(path) => FileSystemEntity.typeSync(path, followLinks: false))(
resolvedFilePath,
);
switch (entityType) {
case FileSystemEntityType.file:
return;
case FileSystemEntityType.notFound:
throw PreviewException('File not found: $resolvedFilePath');
case FileSystemEntityType.directory:
case FileSystemEntityType.link:
case FileSystemEntityType.pipe:
case FileSystemEntityType.unixDomainSock:
throw PreviewException('Path is not a file: $resolvedFilePath');
}
}