class ChunkedDecompressor

Defined at line 45 of file ../../src/lib/chunked-compression/chunked-decompressor.h

ChunkedDecompressor allows chunked archives to be decompressed (either a frame at a time, or in

full).

Usage (error checks omitted):

// Load the header into memory.

const void* header = InputDataHeader();

size_t header_length = 8192; // Read-ahead size for the file header

size_t compressed_length = InputLength(); // Assume >8192

HeaderReader reader;

SeekTable table = reader.Parse(header, header_length, compressed_length);

ChunkedDecompressor decompressor;

size_t target_offset = TargetOffset();

unsigned table_index = table.EntryForDecompressedOffset(TargetOffset()).get();

const SeekTableEntry

&

entry = table.Entries()[table_index];

fbl::Array

<uint8

_t> output_buffer(new uint8_t[entry.decompressed_size],

entry.decompressed_size);

size_t input_chunk_size = entry.compressed_size;

const uint8_t *input_chunk = LoadCompressedData(entry.compressed_offset, input_chunk_size);

size_t bytes_written;

decompressor.DecompressFrame(table, table_index, input_chunk, input_chunk_size,

output_buffer.get(), output_buffer.size(),

&bytes

_written);

Public Methods

void ChunkedDecompressor ()

Defined at line 34 of file ../../src/lib/chunked-compression/chunked-decompressor.cc

void ~ChunkedDecompressor ()

Defined at line 36 of file ../../src/lib/chunked-compression/chunked-decompressor.cc

Status DecompressBytes (const void * input, size_t len, fbl::Array<uint8_t> * output, size_t * bytes_written_out)

Convenience method to do a one-shot decompression of |input|, returning an allocated buffer

containing the decompressed bytes.

Defined at line 38 of file ../../src/lib/chunked-compression/chunked-decompressor.cc

void ChunkedDecompressor (ChunkedDecompressor && o)

Defined at line 49 of file ../../src/lib/chunked-compression/chunked-decompressor.h

ChunkedDecompressor & operator= (ChunkedDecompressor && o)

Defined at line 50 of file ../../src/lib/chunked-compression/chunked-decompressor.h

void ChunkedDecompressor (const ChunkedDecompressor & )

Defined at line 51 of file ../../src/lib/chunked-compression/chunked-decompressor.h

ChunkedDecompressor & operator= (const ChunkedDecompressor & )

Defined at line 51 of file ../../src/lib/chunked-compression/chunked-decompressor.h

Status Decompress (const SeekTable & table, const void * input, size_t len, void * output, size_t output_len, size_t * bytes_written_out)

Reads the decompressed archive described by |table| from |input|, and writes the decompressed

data to |output|.

|input| should include the full archive contents, including the table itself. The table is

not validated (having already been validated during construction of |table|).

|output_len| must be at least |ComputeOutputSize(table)| bytes long.

Returns the number of decompressed bytes written in |bytes_written_out|.

Defined at line 58 of file ../../src/lib/chunked-compression/chunked-decompressor.cc

size_t ComputeOutputSize (const SeekTable & table)

Returns the minimum size that a buffer must be to hold the result of decompressing the archive

described by |table|.

Defined at line 60 of file ../../src/lib/chunked-compression/chunked-decompressor.h

Status DecompressFrame (const void * input_frame, size_t input_frame_len, void * output, size_t output_len, size_t * bytes_written_out)

|input_frame| should start at the frame's first byte, and |input_frame_len| must be big enough

to span the entire frame.

|output| starts at the first byte to write the result, and |output_len| must be the resulting

decompressed size.

Returns the number of decompressed bytes written in |bytes_written_out|.

Defined at line 88 of file ../../src/lib/chunked-compression/chunked-decompressor.cc

Status DecompressFrame (const SeekTable & table, unsigned int table_index, const void * input_frame, size_t input_frame_len, void * output, size_t output_len, size_t * bytes_written_out)

Reads the |table_index|'th frame of the decompressed archive described by |table| from

|input_frame|, and writes the decompressed frame to |output|.

|input_frame| should start at the frame's first byte, and |input_frame_len| must be big enough

to span the entire frame.

|output_len| must be at least as big as |table.Entries()[table_index].decompressed_size|.

Returns the number of decompressed bytes written in |bytes_written_out|.

Defined at line 112 of file ../../src/lib/chunked-compression/chunked-decompressor.cc