Photon 1.0.0
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1#include <cstdlib>
2
3namespace gzip
4{
5
6 // These live in gzip.hpp because it doesnt need to use deps.
7 // Otherwise, they would need to live in impl files if these methods used
8 // zlib structures or functions like inflate/deflate)
9 inline bool is_compressed(const char* data, std::size_t size)
10 {
11 return size > 2 && (
12 // zlib
13 (static_cast<uint8_t>(data[0]) == 0x78 &&
14 (static_cast<uint8_t>(data[1]) == 0x9C || static_cast<uint8_t>(data[1]) == 0x01 ||
15 static_cast<uint8_t>(data[1]) == 0xDA || static_cast<uint8_t>(data[1]) == 0x5E)) ||
16 // gzip
17 (static_cast<uint8_t>(data[0]) == 0x1F && static_cast<uint8_t>(data[1]) == 0x8B));
18 }
19} // namespace gzip
Definition compress.hpp:12
bool is_compressed(const char *data, std::size_t size)
Definition utils.hpp:9
Definition format.h:1901