1 /* 2 * UAE - The Un*x Amiga Emulator 3 * 4 * routines to handle compressed file automatically 5 * 6 * (c) 1996 Samuel Devulder 7 */ 8 9 #ifndef UAE_ZFILE_H 10 #define UAE_ZFILE_H 11 12 #include "uae/types.h" 13 #ifdef FSUAE 14 #include <stddef.h> 15 #endif 16 17 struct zfile; 18 struct zvolume; 19 struct zdirectory; 20 21 #define FS_DIRECTORY 0 22 #define FS_ARCHIVE 1 23 #define FS_CDFS 2 24 25 struct fs_dirhandle 26 { 27 int fstype; 28 union { 29 struct zdirectory *zd; 30 struct my_opendir_s *od; 31 struct cd_opendir_s *isod; 32 }; 33 }; 34 struct fs_filehandle 35 { 36 int fstype; 37 union { 38 struct zfile *zf; 39 struct my_openfile_s *of; 40 struct cd_openfile_s *isof; 41 }; 42 }; 43 44 typedef int (*zfile_callback)(struct zfile*, void*); 45 46 extern struct zfile *zfile_fopen (const TCHAR *, const TCHAR *, int mask); 47 extern struct zfile *zfile_fopen (const TCHAR *, const TCHAR *); 48 extern struct zfile *zfile_fopen (const TCHAR *, const TCHAR *, int mask, int index); 49 extern struct zfile *zfile_fopen_empty (struct zfile*, const TCHAR *name, uae_u64 size); 50 extern struct zfile *zfile_fopen_empty (struct zfile*, const TCHAR *name); 51 extern struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, const uae_u8 *data); 52 extern struct zfile *zfile_fopen_load_zfile (struct zfile *f); 53 extern uae_u8 *zfile_load_data (const TCHAR *name, const uae_u8 *data,int datalen, int *outlen); 54 extern uae_u8 *zfile_load_file(const TCHAR *name, int *outlen); 55 extern struct zfile *zfile_fopen_parent (struct zfile*, const TCHAR*, uae_u64 offset, uae_u64 size); 56 57 extern int zfile_exists (const TCHAR *name); 58 extern void zfile_fclose (struct zfile *); 59 extern uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode); 60 extern uae_s64 zfile_ftell (struct zfile *z); 61 extern uae_s64 zfile_size (struct zfile *z); 62 extern size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z); 63 extern size_t zfile_fwrite (const void *b, size_t l1, size_t l2, struct zfile *z); 64 extern TCHAR *zfile_fgets (TCHAR *s, int size, struct zfile *z); 65 extern char *zfile_fgetsa (char *s, int size, struct zfile *z); 66 extern size_t zfile_fputs (struct zfile *z, const TCHAR *s); 67 extern int zfile_getc (struct zfile *z); 68 extern int zfile_putc (int c, struct zfile *z); 69 extern int zfile_ferror (struct zfile *z); 70 extern uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len); 71 extern void zfile_exit (void); 72 extern int execute_command (TCHAR *); 73 extern int zfile_iscompressed (struct zfile *z); 74 extern int zfile_zcompress (struct zfile *dst, void *src, int size); 75 extern int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize); 76 extern int zfile_gettype (struct zfile *z); 77 extern int zfile_zopen (const TCHAR *name, zfile_callback zc, void *user); 78 extern TCHAR *zfile_getname (struct zfile *f); 79 extern TCHAR *zfile_getoriginalname (struct zfile *f); 80 extern TCHAR *zfile_getfilename (struct zfile *f); 81 extern uae_u32 zfile_crc32 (struct zfile *f); 82 extern struct zfile *zfile_dup (struct zfile *f); 83 extern struct zfile *zfile_gunzip (struct zfile *z); 84 extern int zfile_is_diskimage (const TCHAR *name); 85 extern int iszip (struct zfile *z); 86 extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst); 87 extern struct zfile *zuncompress (struct znode*, struct zfile *z, int dodefault, int mask, int *retcode, int index); 88 extern void zfile_seterror (const TCHAR *format, ...); 89 extern TCHAR *zfile_geterror (void); 90 extern int zfile_truncate (struct zfile *z, uae_s64 size); 91 92 #define ZFD_NONE 0 93 #define ZFD_ARCHIVE 1 //zip/lha.. 94 #define ZFD_ADF 2 //adf as a filesystem 95 #define ZFD_HD 4 //rdb/hdf 96 #define ZFD_UNPACK 8 //gzip,dms 97 #define ZFD_RAWDISK 16 //fdi->adf,ipf->adf etc.. 98 #define ZFD_CD 32 //cue/iso, cue has priority over iso 99 #define ZFD_DISKHISTORY 0x100 //allow diskhistory (if disk image) 100 #define ZFD_CHECKONLY 0x200 //file exists checkc 101 #define ZFD_DELAYEDOPEN 0x400 //do not unpack, just get metadata 102 #define ZFD_NORECURSE 0x10000 // do not recurse archives 103 #define ZFD_NORMAL (ZFD_ARCHIVE|ZFD_UNPACK) 104 #define ZFD_ALL 0x0000ffff 105 106 #define ZFD_RAWDISK_AMIGA 0x10000 107 #define ZFD_RAWDISK_PC 0x200000 108 109 #define ZFILE_UNKNOWN 0 110 #define ZFILE_CONFIGURATION 1 111 #define ZFILE_DISKIMAGE 2 112 #define ZFILE_ROM 3 113 #define ZFILE_KEY 4 114 #define ZFILE_HDF 5 115 #define ZFILE_STATEFILE 6 116 #define ZFILE_NVR 7 117 #define ZFILE_HDFRDB 8 118 #define ZFILE_CDIMAGE 9 119 120 extern const TCHAR *uae_archive_extensions[]; 121 extern const TCHAR *uae_ignoreextensions[]; 122 extern const TCHAR *uae_diskimageextensions[]; 123 124 extern struct zvolume *zfile_fopen_archive (const TCHAR *filename); 125 extern struct zvolume *zfile_fopen_archive (const TCHAR *filename, int flags); 126 extern struct zvolume *zfile_fopen_archive_root (const TCHAR *filename, int flags); 127 extern void zfile_fclose_archive (struct zvolume *zv); 128 extern int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp); 129 extern int zfile_stat_archive (const TCHAR *path, struct mystat *statbuf); 130 extern struct zdirectory *zfile_opendir_archive (const TCHAR *path); 131 extern struct zdirectory *zfile_opendir_archive (const TCHAR *path, int flags); 132 extern void zfile_closedir_archive (struct zdirectory *); 133 extern int zfile_readdir_archive (struct zdirectory *, TCHAR*); 134 extern int zfile_readdir_archive (struct zdirectory *, TCHAR*, bool fullpath); 135 extern struct zfile *zfile_readdir_archive_open (struct zdirectory *zd, const TCHAR *mode); 136 extern void zfile_resetdir_archive (struct zdirectory *); 137 extern int zfile_fill_file_attrs_archive (const TCHAR *path, int *isdir, int *flags, TCHAR **comment); 138 extern uae_s64 zfile_lseek_archive (struct zfile *d, uae_s64 offset, int whence); 139 extern uae_s64 zfile_fsize_archive (struct zfile *d); 140 extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int size); 141 extern void zfile_close_archive (struct zfile *d); 142 extern struct zfile *zfile_open_archive (const TCHAR *path, int flags); 143 extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel); 144 extern bool zfile_needwrite (struct zfile*); 145 146 struct mytimeval 147 { 148 uae_s64 tv_sec; 149 uae_s32 tv_usec; 150 }; 151 152 struct mystat 153 { 154 uae_s64 size; 155 uae_u32 mode; 156 struct mytimeval mtime; 157 }; 158 extern void timeval_to_amiga (struct mytimeval *tv, int* days, int* mins, int* ticks, int tickcount); 159 extern void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int tickcount); 160 161 #endif /* UAE_ZFILE_H */ 162