RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.fs.util.CompressionUtil Class Reference

A static-utility class containing containing extension or helper methods for compressor-deccompressor's. More...

Static Public Member Functions

static byte[] gunzip (byte[] data) throws IOException
 Uncompresses a byte array of g-zipped data.
static byte[] unbzip2 (byte[] data) throws IOException
 Uncompresses a byte array of b-zipped data.
static byte[] unbzip2Headerless (byte[] data, int offset, int length) throws IOException
 Uncompresses a byte array of b-zipped data that does not contain a header.

Private Member Functions

 CompressionUtil ()
 Suppresses the default-public constructor preventing this class from being instantiated by other classes.

Detailed Description

A static-utility class containing containing extension or helper methods for compressor-deccompressor's.

Author
Ryley Kimmel ryley.nosp@m..kim.nosp@m.mel@l.nosp@m.ive..nosp@m.com

Definition at line 17 of file CompressionUtil.java.

Constructor & Destructor Documentation

◆ CompressionUtil()

com.runehive.fs.util.CompressionUtil.CompressionUtil ( )
private

Suppresses the default-public constructor preventing this class from being instantiated by other classes.

Exceptions
UnsupportedOperationExceptionIf this class is instantiated within itself.

Definition at line 71 of file CompressionUtil.java.

71 {
72 throw new UnsupportedOperationException("static-utility classes may not be instantiated.");
73 }

Member Function Documentation

◆ gunzip()

byte[] com.runehive.fs.util.CompressionUtil.gunzip ( byte[] data) throws IOException
static

Uncompresses a byte array of g-zipped data.

Parameters
dataThe compressed, g-zipped data.
Returns
The uncompressed data.
Exceptions
IOExceptionIf some I/O exception occurs.

Definition at line 25 of file CompressionUtil.java.

25 {
26 return toByteArray(new GZIPInputStream(new ByteArrayInputStream(data)));
27 }

Referenced by com.runehive.fs.cache.decoder.RegionDecoder.load().

Here is the caller graph for this function:

◆ unbzip2()

byte[] com.runehive.fs.util.CompressionUtil.unbzip2 ( byte[] data) throws IOException
static

Uncompresses a byte array of b-zipped data.

Parameters
dataThe compressed, b-zipped data.
Returns
The uncompressed data.
Exceptions
IOExceptionIf some I/O exception occurs.

Definition at line 61 of file CompressionUtil.java.

61 {
62 return toByteArray(new CBZip2InputStream(new ByteArrayInputStream(data)));
63 }

Referenced by unbzip2Headerless().

Here is the caller graph for this function:

◆ unbzip2Headerless()

byte[] com.runehive.fs.util.CompressionUtil.unbzip2Headerless ( byte[] data,
int offset,
int length ) throws IOException
static

Uncompresses a byte array of b-zipped data that does not contain a header.

A b-zip header block consists of 2 bytes, they are replaced with 'h' and '1' as that is what our file system compresses the header as.

Parameters
dataThe compressed, b-zipped data.
offsetThe offset position of the data.
lengthThe length of the data.
Returns
The uncompressed data.
Exceptions
IOExceptionIf some I/O exception occurs.

Definition at line 44 of file CompressionUtil.java.

44 {
45 /* Strip the header from the data. */
46 byte[] bzip2 = new byte[length + 2];
47 bzip2[0] = 'h';
48 bzip2[1] = '1';
49 System.arraycopy(data, offset, bzip2, 2, length);
50
51 /* Uncompress the headerless data */
52 return unbzip2(bzip2);
53 }

References unbzip2().

Referenced by com.runehive.fs.cache.archive.Archive.decode().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: