T Binary

Custom Binary

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',
        );
    },
);

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

Libraries

t_binary
Support for doing something awesome.