fileSync method
Converts the input
file and returns a HashDigest synchronously.
If start
is present, the file will be read from byte-offset start
.
Otherwise from the beginning (index 0).
If end
is present, only bytes up to byte-index end
will be read.
Otherwise, until end of file.
If bufferSize
is present, the file will be read in chunks of this size.
By default the bufferSize
is 2048
.
Implementation
HashDigest fileSync(
File input, {
int start = 0,
int? end,
int bufferSize = 2048,
}) {
final raf = input.openSync();
try {
final sink = createSink();
final buffer = Uint8List(bufferSize);
final int length = end ?? raf.lengthSync();
for (int i = start, l; i < length; i += l) {
l = raf.readIntoSync(buffer);
sink.add(buffer, 0, l);
}
return sink.digest();
} finally {
raf.closeSync();
}
}