packio-simple

diff include/packio.h @ 0:d81c3ae262a0

initial commit
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sun, 09 Sep 2012 06:05:11 +0300
parents
children eb07de55d0e6
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/packio.h	Sun Sep 09 06:05:11 2012 +0300
     1.3 @@ -0,0 +1,50 @@
     1.4 +#ifndef PACKIO_H_
     1.5 +#define PACKIO_H_
     1.6 +
     1.7 +struct pack_file;
     1.8 +struct pack_dir;
     1.9 +
    1.10 +#define PACK_NAME_MAX	256
    1.11 +
    1.12 +struct pack_dirent {
    1.13 +	char d_name[PACK_NAME_MAX];
    1.14 +};
    1.15 +
    1.16 +/* not sure I like this capitalization, but it matches the libc counterparts */
    1.17 +typedef struct pack_file PACKFILE;
    1.18 +typedef struct pack_dir PACKDIR;
    1.19 +
    1.20 +
    1.21 +int pack_init(void);
    1.22 +void pack_cleanup(void);
    1.23 +int pack_mount(const char *fname, const char *path);
    1.24 +
    1.25 +int pack_exists(const char *path);
    1.26 +int pack_isfile(const char *path);
    1.27 +int pack_isdir(const char *path);
    1.28 +
    1.29 +
    1.30 +/* file i/o */
    1.31 +PACKFILE *pack_fopen(const char *path, const char *mode);
    1.32 +int pack_fclose(PACKFILE *fp);
    1.33 +
    1.34 +int pack_feof(PACKFILE *fp);
    1.35 +long pack_filesize(PACKFILE *fp);
    1.36 +
    1.37 +int pack_fseek(PACKFILE *fp, long offs, int whence);
    1.38 +long pack_ftell(PACKFILE *fp);
    1.39 +void pack_rewind(PACKFILE *fp);
    1.40 +
    1.41 +size_t pack_fread(void *ptr, size_t size, size_t nmemb, PACKFILE *fp);
    1.42 +size_t pack_fwrite(void *ptr, size_t size, size_t nmemb, PACKFILE *fp);
    1.43 +
    1.44 +int pack_fgetc(PACKFILE *fp);
    1.45 +char *pack_fgets(char *buf, int size, PACKFILE *fp);
    1.46 +
    1.47 +/* directory handling */
    1.48 +PACKDIR *pack_opendir(const char *name);
    1.49 +int pack_closedir(PACKDIR *dir);
    1.50 +struct pack_dirent *pack_readdir(PACKDIR *dir);
    1.51 +
    1.52 +
    1.53 +#endif	/* PACKIO_H_ */