Brotli Archive Library
Install
npm i @simonekruegel/brar
Usage
import BrarManager from '@simonekruegel/brar'
// Open archive
const manager = new BrarManager('./some-archive.brar')
// Add file to archive
manager.addFile('/some-path.txt', someBuffer) // someBuffer needs to be Node.js Buffer
// Write and compress the archive
manager.save()
// Load an existing archive
manager.load()
// Retrieve the decompressed data of the file
const data = manager.getFile('/some-path.txt')
Specification
All ints are Big Endian (BE)
{# HEADER
4 Bytes = String = "BRAR" (utf8)
4 Bytes = Uint32 = File Count
4 Bytes = Uint32 = File Table Offset
4 Bytes = Uint32 = File Table Size
4 Bytes = Uint32 = File Table Size (Compressed)
#}
{# BODY
{ For File Count {
{ Compressed (brotli)
{File Size (Compressed)} Bytes = Uint8[] = File Data
}
}}
#}
{# FILE TABLE
{ Compressed (brotli)
{ For File Count {
4 Bytes = Uint32 = File Name Length
{File Name Length} Bytes = String = File Name (utf8)
4 Bytes = Uint32 = File Offset
4 Bytes = Uint32 = File Size
4 Bytes = Uint32 = File Size (Compressed)
}}
}
#}