t_binary 2.0.0
t_binary: ^2.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 [...]
T Binary #
Custom Binary #
Version 2.0.0 #
🔹 New Features 🧩 ZLibEncoder & ZLibDecoder Integration
English #
Added compression and decompression support using ZLibEncoder and ZLibDecoder from Dart’s dart:io library.
ZLibEncoder compresses files before writing to the binary archive, reducing file size and saving storage space.
ZLibDecoder decompresses data when extracting files, restoring them to their original state. This improves storage efficiency and maintains fast read/write performance.
မြန်မာဘာသာ #
Version 2 မှာ dart:io library ထဲက ZLibEncoder နဲ့ ZLibDecoder ကိုအသုံးပြုပြီး ဖိုင်ချုံ့ခြင်းနဲ့ ဖြေခြင်း လုပ်နိုင်အောင် ထပ်တိုး ထည့်သွင်းထားပါတယ်။
ZLibEncoder က ဖိုင်ကို archive ထဲသို့ သိမ်းမယ့်အခါ data ကိုချုံ့ပေးတာကြောင့် file size လျှော့ချနိုင်ပြီး storage space သက်သာစေပါတယ်။
ZLibDecoder က ဖိုင်ပြန်ဖတ်တဲ့အခါ ချုံ့ထားတဲ့ data ကိုပြန်ဖြေပြီး မူလအတိုင်း ပြန်ရအောင်လုပ်ပေးပါတယ်။
ဒီ feature အသစ်ကြောင့် binary file format ဟာ ပိုပြီး compact ဖြစ်သလို read/write speed လည်း မြန်ပါတယ်။
Overview #
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 efficiently using streaming techniques.
Myanmar #
TBinary သည် high-performance custom binary file format ဖန်တီးရန်အတွက် Dart-based library ဖြစ်ပြီး header metadata, optional cover, multiple file entries, and large file data ကို streaming နည်းလမ်းဖြင့် handle လုပ်နိုင်စေရန် design လုပ်ထားသည်။
Usage #
// write
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',
);
},
);
// read
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',
);
},
);
//add
await TBinary.addEntry(
'compress.tzip',
BFileEntry(
file: File('/home/than/Videos/Sai_Sai_Kham_Leng_Feat._Frenzo_Artists.mp4'),
isCompress: true,
),
onProgress: (loaded, total, message) {
print(
'Progress: ${((loaded / total) * 100).toStringAsFixed(2)}% - message: $message',
);
},
);
//delete
await TBinary.deleteEntry(
'compress.tzip',
'Sai_Sai_Kham_Leng_Feat._Frenzo_Artists.mp4',
onProgress: (loaded, total, message) {
print(
'Progress: ${((loaded / total) * 100).toStringAsFixed(2)}% - message: $message',
);
},
);
Key Features #
Flexible Header #
JSON format header support
Application-specific metadata (e.g., version, author, timestamp) ကို စိတ်တိုင်းကျ ထည့်နိုင်သည်
Optional Cover #
Cover image သို့မဟုတ် အခြား binary data ကို optional အနေနဲ့ ထည့်နိုင်သည်
Cover presence flag နဲ့ automatically detect လုပ်နိုင်သည်
File List with Offsets #
Binary file ထဲရှိ file entries အား name, size, offset အပြည့်အစုံ record လုပ်သည်
Offset သည် file data အစအနေအတိုင်း automatically calculate လုပ်သည်
Large File Support (Streaming-Friendly):
3GB+ အထိ file data ကို memory full မဖြစ်စေရန် chunk-based streaming နည်းလမ်းသုံးသည်
RandomAccessFile နှင့် streaming read/write ဖြင့် efficiency အမြင့်ဆုံးထားသည်
Dart OOP Design #
Binary file operations (write, read) ကို object-oriented structure ဖြင့် organize လုပ်ထားသည်
Modular classes: CustomBinaryFile, BinaryFileEntry
Cross-Platform #
Dart/Flutter ecosystem မှာ အသုံးပြုနိုင်ပြီး, large files handling နှင့် metadata management ကို simplify လုပ်ပေးသည်
Use Cases #
Custom archive formats (like ZIP replacement)
Game assets packaging
Large dataset distribution
Multimedia storage (cover + files)
Advantages #
Memory-efficient large file support
Structured metadata + optional cover
Easy-to-use API for reading and writing binary files
Dart-native, easy integration into Flutter apps