Lephisto/src/pack.h

33 lines
963 B
C

#pragma once
#include <fcntl.h>
#ifndef _POSIX_SOURCE /* No posix. */
#include <stdio.h>
#endif
#include <stdint.h>
typedef struct Packfile_ {
#ifdef _POSIX_SOURCE
int fd; /* File descriptor. */
#else
FILE* fp;
#endif
uint32_t pos; /* position. */
uint32_t start, end; /* file limits. */
} 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);