1#ifndef BYTEME_MAGIC_NUMBERS_HPP
2#define BYTEME_MAGIC_NUMBERS_HPP
6#include "SelfClosingFILE.hpp"
20inline bool is_zlib(
const unsigned char* buffer, std::size_t n) {
21 if (n >= 2 && buffer[0] == 0x78) {
22 auto level = buffer[1];
24 if (level == 0x01 || level == 0x5e || level == 0x9c || level == 0xda || level == 0x20 || level == 0x7d || level == 0xbb || level == 0xf9) {
36inline bool is_gzip(
const unsigned char* buffer, std::size_t n) {
38 return (n >= 2 && buffer[0] == 0x1f && buffer[1] == 0x8b);
46 SelfClosingFILE file(path,
"rb");
47 unsigned char header[3];
48 auto read = std::fread(header,
sizeof(
unsigned char), 3, file.handle);
Simple byte readers and writers.
bool is_gzip(const unsigned char *buffer, std::size_t n)
Definition magic_numbers.hpp:36
bool is_zlib(const unsigned char *buffer, std::size_t n)
Definition magic_numbers.hpp:20