Pioneer
Loading...
Searching...
No Matches
GZipFormat.h
Go to the documentation of this file.
1// Copyright © 2017 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef GZIP_FORMAT_H
5#define GZIP_FORMAT_H
6
7#include <string>
8
9namespace gzip {
10 struct GZipException {};
13
14 // Checks if the data block could plausibly be a GZip file.
15 // This really just checks for the magic GZip bytes and a basic length check.
16 bool IsGZipFormat(const unsigned char *data, size_t length);
17
18 // Decompresses a compressed block.
19 // If the input starts with GZip header marker bytes then it will interpret the input as GZip data.
20 // If the input does not start with the GZip header marker then it will assume it's a plain DEFLATE
21 // input and decompress it as such.
22 std::string DecompressDeflateOrGZip(const unsigned char *data, size_t length);
23
24 // Decompress GZip format data.
25 // This tries to follow RFC 1952 (GZip format).
26 // If the input fails format or CRC checks then it will throw an exception.
27 std::string DecompressGZip(const unsigned char *data, size_t length);
28
29 // Wrapper for miniz inflate function; assumes no header.
30 std::string DecompressRawDeflate(const unsigned char *data, size_t length);
31
32 // Compresses a block of data and adds a GZip format header.
33 // This tries to follow RFC 1952 (GZip format).
34 // If compression fails it throws an exception.
35 // Parameter 'inner_file_name' is the name written in the GZip header as the file name of the compressed block.
36 std::string CompressGZip(const std::string &data, const std::string &inner_file_name);
37} // namespace gzip
38
39#endif
Definition GZipFormat.h:9
std::string DecompressGZip(const unsigned char *data, size_t length)
Definition GZipFormat.cpp:78
std::string CompressGZip(const std::string &data, const std::string &inner_file_name)
Definition GZipFormat.cpp:183
std::string DecompressRawDeflate(const unsigned char *data, size_t length)
Definition GZipFormat.cpp:171
bool IsGZipFormat(const unsigned char *data, size_t length)
Definition GZipFormat.cpp:55
std::string DecompressDeflateOrGZip(const unsigned char *data, size_t length)
Definition GZipFormat.cpp:67
Definition GZipFormat.h:12
Definition GZipFormat.h:11
Definition GZipFormat.h:10