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