| OLD | NEW |
| 1 /* ioapi.h -- IO base function header for compress/uncompress .zip | 1 /* ioapi.h -- IO base function header for compress/uncompress .zip |
| 2 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
) | 2 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html
) |
| 3 | 3 |
| 4 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.
com/zLibDll/minizip.html ) | 4 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.
com/zLibDll/minizip.html ) |
| 5 | 5 |
| 6 Modifications for Zip64 support | 6 Modifications for Zip64 support |
| 7 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | 7 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
| 8 | 8 |
| 9 For more info read MiniZip_info.txt | 9 For more info read MiniZip_info.txt |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 mode_fopen = "r+b"; | 109 mode_fopen = "r+b"; |
| 110 else | 110 else |
| 111 if (mode & ZLIB_FILEFUNC_MODE_CREATE) | 111 if (mode & ZLIB_FILEFUNC_MODE_CREATE) |
| 112 mode_fopen = "wb"; | 112 mode_fopen = "wb"; |
| 113 | 113 |
| 114 if ((filename!=NULL) && (mode_fopen != NULL)) | 114 if ((filename!=NULL) && (mode_fopen != NULL)) |
| 115 file = fopen64((const char*)filename, mode_fopen); | 115 file = fopen64((const char*)filename, mode_fopen); |
| 116 return file; | 116 return file; |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Google |
| 120 voidpf ZCALLBACK fdopen_file_func (opaque, filename, mode) |
| 121 voidpf opaque; |
| 122 const char* filename; |
| 123 int mode; |
| 124 { |
| 125 FILE* file = NULL; |
| 126 const char* mode_fopen = NULL; |
| 127 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 128 mode_fopen = "rb"; |
| 129 else |
| 130 if (mode & ZLIB_FILEFUNC_MODE_EXISTING) |
| 131 mode_fopen = "r+b"; |
| 132 else |
| 133 if (mode & ZLIB_FILEFUNC_MODE_CREATE) |
| 134 mode_fopen = "wb"; |
| 135 |
| 136 if ((filename!=NULL) && (mode_fopen != NULL)) |
| 137 file = fdopen(*(int*)opaque, mode_fopen); |
| 138 return file; |
| 139 } |
| 140 |
| 119 | 141 |
| 120 static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf,
uLong size) | 142 static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf,
uLong size) |
| 121 { | 143 { |
| 122 uLong ret; | 144 uLong ret; |
| 123 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); | 145 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
| 124 return ret; | 146 return ret; |
| 125 } | 147 } |
| 126 | 148 |
| 127 static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi
d* buf, uLong size) | 149 static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const voi
d* buf, uLong size) |
| 128 { | 150 { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 { | 248 { |
| 227 pzlib_filefunc_def->zopen64_file = fopen64_file_func; | 249 pzlib_filefunc_def->zopen64_file = fopen64_file_func; |
| 228 pzlib_filefunc_def->zread_file = fread_file_func; | 250 pzlib_filefunc_def->zread_file = fread_file_func; |
| 229 pzlib_filefunc_def->zwrite_file = fwrite_file_func; | 251 pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 230 pzlib_filefunc_def->ztell64_file = ftell64_file_func; | 252 pzlib_filefunc_def->ztell64_file = ftell64_file_func; |
| 231 pzlib_filefunc_def->zseek64_file = fseek64_file_func; | 253 pzlib_filefunc_def->zseek64_file = fseek64_file_func; |
| 232 pzlib_filefunc_def->zclose_file = fclose_file_func; | 254 pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 233 pzlib_filefunc_def->zerror_file = ferror_file_func; | 255 pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 234 pzlib_filefunc_def->opaque = NULL; | 256 pzlib_filefunc_def->opaque = NULL; |
| 235 } | 257 } |
| 258 |
| 259 // Google |
| 260 void fill_fdopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def, int fd) |
| 261 { |
| 262 fill_fopen_filefunc(pzlib_filefunc_def); |
| 263 pzlib_filefunc_def->zopen_file = fdopen_file_func; |
| 264 int *ptr_fd = malloc(sizeof(int)); |
| 265 *ptr_fd = fd; |
| 266 pzlib_filefunc_def->opaque = ptr_fd; |
| 267 } |
| OLD | NEW |