#pragma once #include #ifndef _POSIX_SOURCE /* No posix. */ #include #endif #include #include /** * @struct Packfile * * @brief Abstracts around packfile */ typedef struct Packfile_ { #ifdef _POSIX_SOURCE int fd; /**< File descriptor. */ #else FILE* fp; /**< For non-posix. */ #endif uint32_t pos; /**< position. */ uint32_t start; /**< File start */ uint32_t end; /**< File end. */ } Packfile; /* Packfile manipulation. Automatically allocated and freed (with open and close). */ /* Basic. */ int pack_check(const char* filename); int pack_files(const char* outfile, const char** infiles, const uint32_t nfiles); int pack_open(Packfile* file, const char* packfile, const char* filename); ssize_t pack_read(Packfile* file, void* buf, const size_t count); off_t pack_seek(Packfile* file, off_t offset, int whence); long pack_tell(Packfile* file); int pack_close(Packfile* file); /* Fancy stuff. */ void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesize); char** pack_listfiles(const char* packfile, uint32_t* nfiles);