Initial release: July 2007
Daniel Keep
- class BzipOutput : OutputFilter ¶
-
This output filter can be used to perform compression of data into a bzip2
stream.
- enum BlockSize : int ¶
-
This enumeration represents several pre-defined compression block
sizes, measured in hundreds of kilobytes. See the documentation for
the BzipOutput class' constructor for more details.
- this(OutputStream stream, int blockSize = Normal) ¶
-
Constructs a new bzip2 compression filter. You need to pass in the
stream that the compression filter will write to. If you are using
this filter with a conduit, the idiom to use is:
1
2
|
auto output = new BzipOutput(myConduit.output);
output.write(myContent);
|
blockSize relates to the size of the window bzip2 uses when
compressing data and determines how much memory is required to
decompress a stream. It is measured in hundreds of kilobytes.
ccording to the bzip2 documentation, there is no dramatic difference
between the various block sizes, so the default should suffice in most
cases.
BlockSize.Normal (the default) is the same as BlockSize.Best
(or 9). The blockSize may be any integer between 1 and 9 inclusive.
- void reset(OutputStream stream, int blockSize = Normal) ¶
-
Resets and re-initialises this instance.
If you are creating compression streams inside a loop, you may wish to
use this method to re-use a single instance. This prevents the
potentially costly re-allocation of internal buffers.
The stream must have already been closed before calling reset.
- size_t write(const(void)[] src) [override] ¶
-
Compresses the given data to the underlying conduit.
Returns the number of bytes from src that were compressed, which may
be less than given.
- size_t written() ¶
-
This read-only property returns the number of compressed bytes that
have been written to the underlying stream. Following a call to
either close or commit, this will contain the total compressed size of
the input data stream.
- void close() [override] ¶
-
Close the compression stream. This will cause any buffered content to
be committed to the underlying stream.
- void commit() ¶
-
Purge any buffered content. Calling this will implicitly end the
bzip2 stream, so it should not be called until you are finished
compressing data. Any calls to either write or commit after a
compression filter has been committed will throw an exception.
The only difference between calling this method and calling close is
that the underlying stream will not be closed.
- class BzipInput : InputFilter ¶
-
This input filter can be used to perform decompression of bzip2 streams.
- this(InputStream stream, bool small = false) ¶
-
Constructs a new bzip2 decompression filter. You need to pass in the
stream that the decompression filter will read from. If you are using
this filter with a conduit, the idiom to use is:
1
2
|
auto input = new BzipInput(myConduit.input);
input.read(myContent);
|
The small argument, if set to true, instructs bzip2 to perform
decompression using half the regular amount of memory, at the cost of
running at half speed.
- void reset(InputStream stream, bool small = false) ¶
-
Resets and re-initialises this instance.
If you are creating compression streams inside a loop, you may wish to
use this method to re-use a single instance. This prevents the
potentially costly re-allocation of internal buffers.
The stream must have already been closed before calling reset.
- size_t read(void[] dst) [override] ¶
-
Decompresses data from the underlying conduit into a target array.
Returns the number of bytes stored into dst, which may be less than
requested.
- void close() [override] ¶
-
Closes the compression stream.
- class BzipException : IOException ¶
-
This exception is thrown when an error occurs in the underlying bzip2
library.
- class BzipClosedException : IOException ¶
-
This exception is thrown if you attempt to perform a read, write or flush
operation on a closed bzip2 filter stream. This can occur if the input
stream has finished, or an output stream was flushed.
- class BzipStillOpenException : IOException ¶
-
This exception is thrown if you attempt to reset a compression stream that
is still open. You must either close or commit a stream before it can be
reset.