readFileBytes method
Reads the (inflated) bytes of a file member. Throws when the member is missing, a directory, or exceeds maxArchiveMemberBytes declared.
Implementation
Uint8List readFileBytes(String subPath) {
final normalizedPath = normalizeArchiveLookupPath(subPath);
if (normalizedPath == null) {
throw StateError("Archive path cannot contain '..'");
}
final entry = _entries[normalizedPath];
if (entry == null) {
throw StateError("Archive path '$normalizedPath' not found");
}
if (entry.isDirectory) {
throw StateError("Archive path '$normalizedPath' is a directory");
}
if (entry.size > maxArchiveMemberBytes) {
throw StateError(
"Archive entry '$normalizedPath' is too large to read "
'(${entry.size} bytes > $maxArchiveMemberBytes byte limit)',
);
}
final content = entry.file!.content;
return content;
}