Top Documents Download Gallery Repository
Are you looking for a Software Engineer? Check Here

9bzip2 Module

The bzip2 module provices measures to read/write BZIP2 files. To utilize it, import the bzip2 module using import function.

Below is an example to read data from a BZIP2 file and write its uncompressed data to another file.

import(bzip2)
bzip2.reader('foo.dat.bz2').copyto('foo.dat')

Below is an example to read data from a file and write its compressed data to a BZIP2 file.

import(bzip2)
bzip2.writer('foo.dat.bz2').copyfrom('foo.dat')

9.1Module Function

bzip2.reader
bzip2.reader(stream:stream:r) {block?}
Creates a stream instance that decompresses bzip2 data from the specified stream that has readable attribute.

If block is specified, it would be evaluated with a block parameter |st:stream|, where st is the created instance. In this case, the block's result would become the function's returned value.

bzip2.writer
bzip2.writer(stream:stream:w, blockSize100k?:number) {block?}
Creates a stream instance that compresses data into bzip2 format and writes it to the specified stream that has writable attribute.

The argument blockSize100k takes a number between 1 and 9 that specifies the block size to be used for compression. The actual block size is 100000 times of this value. Nine gives the best compression but takes most memory.

If block is specified, it would be evaluated with a block parameter |st:stream|, where st is the created instance. In this case, the block's result would become the function's returned value.

9.2Extension to stream Class

This module extends the stream class with methods described here.

stream#reader@bzip2
stream#reader@bzip2() {block?}
Creates a stream instance that decompresses bzip2 data from the specified stream that has readable attribute.

If block is specified, it would be evaluated with a block parameter |st:stream|, where st is the created instance. In this case, the block's result would become the function's returned value.

stream#writer@bzip2
stream#writer@bzip2(blockSize100k?:number) {block?}
Creates a stream instance that compresses data into bzip2 format and writes it to the specified stream that has writable attribute.

The argument blockSize100k takes a number between 1 and 9 that specifies the block size to be used for compression. The actual block size is 100000 times of this value. Nine gives the best compression but takes most memory.

If block is specified, it would be evaluated with a block parameter |st:stream|, where st is the created instance. In this case, the block's result would become the function's returned value.

9.3Thanks

This module uses libbzip2 which is distributed in the following site:

http://www.bzip.org/


Copyright (C) 2011-2017 ypsitau