1#ifndef BYTEME_RAW_FILE_READER_HPP
2#define BYTEME_RAW_FILE_READER_HPP
11#include "SelfClosingFILE.hpp"
49 std::size_t
read(
unsigned char* buffer, std::size_t n) {
50 auto& handle = my_file.handle;
51 auto read = std::fread(buffer,
sizeof(
unsigned char), n, handle);
52 if (
read < n && std::ferror(handle)) {
53 throw std::runtime_error(
"file read failed");
59 SelfClosingFILE my_file;
Read bytes from a file, usually text.
Definition RawFileReader.hpp:38
std::size_t read(unsigned char *buffer, std::size_t n)
Definition RawFileReader.hpp:49
RawFileReader(const char *path, const RawFileReaderOptions &options)
Definition RawFileReader.hpp:44
Virtual class for reading bytes from a source.
Definition Reader.hpp:17
Simple byte readers and writers.
Definition BufferedReader.hpp:21
Options for the RawFileReader constructor.
Definition RawFileReader.hpp:24
std::optional< std::size_t > buffer_size
Definition RawFileReader.hpp:30