1#ifndef BYTEME_SOME_FILE_READER_HPP
2#define BYTEME_SOME_FILE_READER_HPP
7#include "magic_numbers.hpp"
32 unsigned char header[3];
35 SelfClosingFILE file(path,
"rb");
36 read = std::fread(header,
sizeof(
unsigned char), 3, file.handle);
39 if (is_gzip(header, read)) {
54 return my_source->load();
57 const unsigned char*
buffer()
const {
58 return my_source->buffer();
62 return my_source->available();
66 std::unique_ptr<Reader> my_source;
Read a Gzip-compressed file.
Read a file without any extra transformations.
Read uncompressed bytes from a Gzip-compressed file.
Definition GzipFileReader.hpp:24
Read bytes from a file, usually text.
Definition RawFileReader.hpp:25
Virtual class for reading bytes from a source.
Definition Reader.hpp:15
Read a file that may or may not be Gzipped.
Definition SomeFileReader.hpp:25
SomeFileReader(const std::string &path, size_t buffer_size=65536)
Definition SomeFileReader.hpp:50
const unsigned char * buffer() const
Definition SomeFileReader.hpp:57
SomeFileReader(const char *path, size_t buffer_size=65536)
Definition SomeFileReader.hpp:31
bool load()
Definition SomeFileReader.hpp:53
size_t available() const
Definition SomeFileReader.hpp:61
Simple byte readers and writers.