bytepack 0.1.0
bytepack: ^0.1.0 copied to clipboard
BytepackCompresser is a Dart utility for efficiently encoding Map<String, dynamic> objects to bytes and compressing files with ZLib, supporting both data serialization and file compression in one package.
import 'dart:io';
import 'package:bytepack/bytepack.dart';
void main() async {
// await compress();
// await deCompress();
}
Future<void> deCompress() async {
final inpFile = File('/home/than/Music/test.mp4.compressed');
final outFile = File('/home/than/Music/test-decompress.mp4');
final inpRaf = await inpFile.open(mode: FileMode.read);
await BytepackCompresser.decompressFromRandomAccessFile(
inputRaf: inpRaf,
outputFile: outFile,
onProgress: (progress, name) => print('progres: $progress % - name: $name'),
);
await inpRaf.close();
}
Future<void> compress() async {
final file = File('/home/than/Music/test.mp4');
final outFile = File('/home/than/Music/test.mp4.compressed');
final outRaf = await outFile.open(mode: FileMode.write);
await BytepackCompresser.compressRandomAccessFile(
file: file,
outputRaf: outRaf,
onProgress: (progress, name) => print('progres: $progress % - name: $name'),
);
await outRaf.close();
}