#pragma once #include #include #include enum allow_flags { O_NOALLOWMAP = 1 << 0, O_NOALLOWSPONGE = 1 << 1, }; enum mapping_type { MT_MMAP, MT_OWNED, }; struct filebuf { char *buf; size_t sz; enum mapping_type mapping_type; }; struct filebuf *stream_to_filebuf(FILE *restrict stream, int openOptions); struct filebuf *file_to_filebuf(char *fname, int openOptions, bool *isdir); void free_filebuf(struct filebuf *filebuf);