t_binary 1.0.0
t_binary: ^1.0.0 copied to clipboard
TBinary is a Dart-based library designed to create a high-performance custom binary file format, capable of handling header metadata, an optional cover, multiple file entries, and large file data effi [...]
import 'dart:io';
import 'package:t_binary/t_binary.dart';
void main() async {
try {
final dist = Directory('dist');
if (!dist.existsSync()) {
await dist.create();
}
final res = await TBinary.readBinary('test.bin');
print(res.header.toMap());
print(res.fileList);
await res.saveCover('cover.png');
await res.extractAll(
dist,
onProgress: (loaded, total, message) {
print(
'Progress: ${((loaded / total) * 100).toStringAsFixed(2)}% - message: $message',
);
},
);
// List<String> filePaths = [
// '/home/than/Music/002-are-you-used-to.mpga',
// '/home/than/Music/test.mp4',
// '/home/than/Music/test.mp3',
// ];
// await TBinary.writeBinary(
// 'test.bin',
// cover: File(
// '/home/than/Pictures/Untitled_logo_4_free-file.jpg',
// ).readAsBytesSync(),
// filePaths: filePaths,
// onProgress: (loaded, total, message) {
// print(
// 'Progress: ${((loaded / total) * 100).toStringAsFixed(2)}% - message: $message',
// );
// },
// );
print('done');
} catch (e) {
print(e.toString());
}
}