~arslee07/hare-nbt

af0f70b7f79f8652a7484e30c3a0575ea09a80bc — arslee07 4 months ago 47fbe9d
Added decompression example
2 files changed, 21 insertions(+), 0 deletions(-)

A cmd/decompress/decompress.ha
A cmd/decompress/level.dat
A cmd/decompress/decompress.ha => cmd/decompress/decompress.ha +21 -0
@@ 0,0 1,21 @@
use fmt;
use format::nbt;
use os;
use io;
use compress::gzip;

export fn main() void = {
	let f = os::open("cmd/decompress/level.dat")!;
	defer io::close(f)!;

	let d = gzip::decompress(f)!;
	let reader = &d.1;
	defer io::close(reader)!;

	let tag = nbt::load(reader)!;
	defer nbt::finish(tag);

	let data = nbt::get(&(tag.payload as nbt::compound), "Data") as *nbt::tag;
	let seed = nbt::get(&(data.payload as nbt::compound), "RandomSeed") as *nbt::tag;
	fmt::println(seed.payload as i64)!;
};

A cmd/decompress/level.dat => cmd/decompress/level.dat +0 -0