readBytes method
Implementation
@override
Future<List<int>> readBytes(EaglePath path) async {
try {
final candidate = _lexical(path);
final type = await FileSystemEntity.type(candidate, followLinks: false);
if (type == FileSystemEntityType.notFound) {
throw EagleSourceException('File does not exist: $path');
}
final resolved = await _resolvedContained(candidate, type);
if (await FileSystemEntity.type(resolved) != FileSystemEntityType.file) {
throw EagleSourceException('Path is not a file: $path');
}
return List<int>.unmodifiable(await File(resolved).readAsBytes());
} on EagleSourceException {
rethrow;
} catch (error) {
throw EagleSourceException('File cannot be read.', cause: error);
}
}