1 /* iowin32.c -- IO base function header for compress/uncompress .zip
2 Version 1.1, February 14h, 2010
3 part of the MiniZip project
4
5 Copyright (C) 1998-2010 Gilles Vollant
6 http://www.winimage.com/zLibDll/minizip.html
7 Modifications for Zip64 support
8 Copyright (C) 2009-2010 Mathias Svensson
9 http://result42.com
10
11 This program is distributed under the terms of the same license as zlib.
12 See the accompanying LICENSE file for the full text of the license.
13 */
14
15 #ifdef WIN32
16 #include <stdlib.h>
17 #include <tchar.h>
18
19 #include "zlib.h"
20 #include "ioapi.h"
21 #include "iowin32.h"
22
23 #ifndef INVALID_HANDLE_VALUE
24 # define INVALID_HANDLE_VALUE (0xFFFFFFFF)
25 #endif
26
27 #ifndef INVALID_SET_FILE_POINTER
28 # define INVALID_SET_FILE_POINTER ((DWORD)-1)
29 #endif
30
31 #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
32 # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
33 # define IOWIN32_USING_WINRT_API 1
34 # endif
35 #endif
36
37 voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
38 uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
39 uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
40 ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
41 long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
42 int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
43 int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
44
45 typedef struct
46 {
47 HANDLE hf;
48 int error;
49 void *filename;
50 int filenameLength;
51 } WIN32FILE_IOWIN;
52
53
win32_translate_open_mode(int mode,DWORD * lpdwDesiredAccess,DWORD * lpdwCreationDisposition,DWORD * lpdwShareMode,DWORD * lpdwFlagsAndAttributes)54 static void win32_translate_open_mode(int mode,
55 DWORD* lpdwDesiredAccess,
56 DWORD* lpdwCreationDisposition,
57 DWORD* lpdwShareMode,
58 DWORD* lpdwFlagsAndAttributes)
59 {
60 *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
61
62 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER) == ZLIB_FILEFUNC_MODE_READ)
63 {
64 *lpdwDesiredAccess = GENERIC_READ;
65 *lpdwCreationDisposition = OPEN_EXISTING;
66 *lpdwShareMode = FILE_SHARE_READ;
67 }
68 else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
69 {
70 *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
71 *lpdwCreationDisposition = OPEN_EXISTING;
72 }
73 else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
74 {
75 *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
76 *lpdwCreationDisposition = CREATE_ALWAYS;
77 }
78 }
79
win32_build_iowin(HANDLE hFile)80 static voidpf win32_build_iowin(HANDLE hFile)
81 {
82 WIN32FILE_IOWIN *iowin = NULL;
83
84 if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
85 {
86 iowin = (WIN32FILE_IOWIN *)malloc(sizeof(WIN32FILE_IOWIN));
87 if (iowin == NULL)
88 {
89 CloseHandle(hFile);
90 return NULL;
91 }
92 memset(iowin, 0, sizeof(WIN32FILE_IOWIN));
93 iowin->hf = hFile;
94 }
95 return (voidpf)iowin;
96 }
97
win32_open64_file_func(voidpf opaque,const void * filename,int mode)98 voidpf ZCALLBACK win32_open64_file_func (voidpf opaque, const void* filename, int mode)
99 {
100 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
101 HANDLE hFile = NULL;
102 WIN32FILE_IOWIN *iowin = NULL;
103
104 win32_translate_open_mode(mode, &dwDesiredAccess, &dwCreationDisposition, &dwShareMode, &dwFlagsAndAttributes);
105
106 if ((filename != NULL) && (dwDesiredAccess != 0))
107 {
108 #ifdef IOWIN32_USING_WINRT_API
109 #ifdef UNICODE
110 hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
111 #else
112 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
113 MultiByteToWideChar(CP_ACP, 0, (const char*)filename, -1, filenameW, FILENAME_MAX + 0x200);
114 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
115 #endif
116 #else
117 hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
118 #endif
119 }
120
121 iowin = win32_build_iowin(hFile);
122 if (iowin == NULL)
123 return NULL;
124 iowin->filenameLength = _tcslen(filename) + 1;
125 iowin->filename = (void*)malloc(iowin->filenameLength * sizeof(TCHAR));
126 _tcsncpy(iowin->filename, filename, iowin->filenameLength);
127 return iowin;
128 }
129
130
win32_open64_file_funcA(voidpf opaque,const void * filename,int mode)131 voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque, const void* filename, int mode)
132 {
133 DWORD dwDesiredAccess, dwCreationDisposition, dwShareMode, dwFlagsAndAttributes ;
134 HANDLE hFile = NULL;
135 WIN32FILE_IOWIN *iowin = NULL;
136
137 win32_translate_open_mode(mode, &dwDesiredAccess, &dwCreationDisposition, &dwShareMode, &dwFlagsAndAttributes);
138
139 if ((filename != NULL) && (dwDesiredAccess != 0))
140 {
141 #ifdef IOWIN32_USING_WINRT_API
142 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
143 MultiByteToWideChar(CP_ACP, 0, (const char*)filename, -1, filenameW, FILENAME_MAX + 0x200);
144 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
145 #else
146 hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
147 #endif
148 }
149
150 iowin = win32_build_iowin(hFile);
151 if (iowin == NULL)
152 return NULL;
153 iowin->filenameLength = strlen(filename) + 1;
154 iowin->filename = (void*)malloc(iowin->filenameLength * sizeof(char));
155 strncpy(iowin->filename, filename, iowin->filenameLength);
156 return iowin;
157 }
158
159
win32_open64_file_funcW(voidpf opaque,const void * filename,int mode)160 voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
161 {
162 DWORD dwDesiredAccess, dwCreationDisposition, dwShareMode, dwFlagsAndAttributes;
163 HANDLE hFile = NULL;
164 WIN32FILE_IOWIN *iowin = NULL;
165
166 win32_translate_open_mode(mode, &dwDesiredAccess, &dwCreationDisposition, &dwShareMode, &dwFlagsAndAttributes);
167
168 if ((filename != NULL) && (dwDesiredAccess != 0))
169 {
170 #ifdef IOWIN32_USING_WINRT_API
171 hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
172 #else
173 hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
174 #endif
175 }
176
177 iowin = win32_build_iowin(hFile);
178 if (iowin == NULL)
179 return NULL;
180 if (iowin->filename == NULL)
181 {
182 iowin->filenameLength = wcslen(filename) + 1;
183 iowin->filename = (void*)malloc(iowin->filenameLength * sizeof(WCHAR));
184 wcsncpy(iowin->filename, filename, iowin->filenameLength);
185 }
186 return iowin;
187 }
188
win32_open_file_func(voidpf opaque,const char * filename,int mode)189 voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
190 {
191 DWORD dwDesiredAccess, dwCreationDisposition, dwShareMode, dwFlagsAndAttributes ;
192 HANDLE hFile = NULL;
193 WIN32FILE_IOWIN *iowin = NULL;
194
195 win32_translate_open_mode(mode, &dwDesiredAccess, &dwCreationDisposition, &dwShareMode, &dwFlagsAndAttributes);
196
197 if ((filename != NULL) && (dwDesiredAccess != 0))
198 {
199 #ifdef IOWIN32_USING_WINRT_API
200 #ifdef UNICODE
201 hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
202 #else
203 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
204 MultiByteToWideChar(CP_ACP, 0, (const char*)filename, -1, filenameW, FILENAME_MAX + 0x200);
205 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
206 #endif
207 #else
208 hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
209 #endif
210 }
211
212 iowin = win32_build_iowin(hFile);
213 if (iowin == NULL)
214 return NULL;
215 iowin->filenameLength = _tcslen(filename) + 1;
216 iowin->filename = (void*)malloc(iowin->filenameLength * sizeof(TCHAR));
217 _tcsncpy(iowin->filename, filename, iowin->filenameLength);
218 return iowin;
219 }
220
win32_opendisk64_file_func(voidpf opaque,voidpf stream,int number_disk,int mode)221 voidpf ZCALLBACK win32_opendisk64_file_func (voidpf opaque, voidpf stream, int number_disk, int mode)
222 {
223 WIN32FILE_IOWIN *iowin = NULL;
224 TCHAR *diskFilename = NULL;
225 voidpf ret = NULL;
226 int i = 0;
227
228 if (stream == NULL)
229 return NULL;
230 iowin = (WIN32FILE_IOWIN*)stream;
231 diskFilename = (TCHAR*)malloc(iowin->filenameLength * sizeof(TCHAR));
232 _tcsncpy(diskFilename, iowin->filename, iowin->filenameLength);
233 for (i = iowin->filenameLength - 1; i >= 0; i -= 1)
234 {
235 if (diskFilename[i] != _T('.'))
236 continue;
237 _sntprintf(&diskFilename[i], iowin->filenameLength - i, _T(".z%02d"), number_disk + 1);
238 break;
239 }
240 if (i >= 0)
241 ret = win32_open64_file_func(opaque, diskFilename, mode);
242 free(diskFilename);
243 return ret;
244 }
245
win32_opendisk64_file_funcW(voidpf opaque,voidpf stream,int number_disk,int mode)246 voidpf ZCALLBACK win32_opendisk64_file_funcW (voidpf opaque, voidpf stream, int number_disk, int mode)
247 {
248 WIN32FILE_IOWIN *iowin = NULL;
249 WCHAR *diskFilename = NULL;
250 voidpf ret = NULL;
251 int i = 0;
252
253 if (stream == NULL)
254 return NULL;
255 iowin = (WIN32FILE_IOWIN*)stream;
256 diskFilename = (WCHAR*)malloc((iowin->filenameLength + 10) * sizeof(WCHAR));
257 wcsncpy(diskFilename, iowin->filename, iowin->filenameLength);
258 for (i = iowin->filenameLength - 1; i >= 0; i -= 1)
259 {
260 if (diskFilename[i] != L'.')
261 continue;
262 _snwprintf(&diskFilename[i], (iowin->filenameLength + 10) - i, L".z%02d", number_disk + 1);
263 break;
264 }
265 if (i >= 0)
266 ret = win32_open64_file_funcW(opaque, diskFilename, mode);
267 free(diskFilename);
268 return ret;
269 }
270
win32_opendisk64_file_funcA(voidpf opaque,voidpf stream,int number_disk,int mode)271 voidpf ZCALLBACK win32_opendisk64_file_funcA (voidpf opaque, voidpf stream, int number_disk, int mode)
272 {
273 WIN32FILE_IOWIN *iowin = NULL;
274 char *diskFilename = NULL;
275 voidpf ret = NULL;
276 int i = 0;
277
278 if (stream == NULL)
279 return NULL;
280 iowin = (WIN32FILE_IOWIN*)stream;
281 diskFilename = (char*)malloc(iowin->filenameLength * sizeof(char));
282 strncpy(diskFilename, iowin->filename, iowin->filenameLength);
283 for (i = iowin->filenameLength - 1; i >= 0; i -= 1)
284 {
285 if (diskFilename[i] != '.')
286 continue;
287 _snprintf(&diskFilename[i], iowin->filenameLength - i, ".z%02d", number_disk + 1);
288 break;
289 }
290 if (i >= 0)
291 ret = win32_open64_file_funcA(opaque, diskFilename, mode);
292 free(diskFilename);
293 return ret;
294 }
295
win32_opendisk_file_func(voidpf opaque,voidpf stream,int number_disk,int mode)296 voidpf ZCALLBACK win32_opendisk_file_func (voidpf opaque, voidpf stream, int number_disk, int mode)
297 {
298 WIN32FILE_IOWIN *iowin = NULL;
299 TCHAR *diskFilename = NULL;
300 voidpf ret = NULL;
301 int i = 0;
302
303 if (stream == NULL)
304 return NULL;
305 iowin = (WIN32FILE_IOWIN*)stream;
306 diskFilename = (TCHAR*)malloc(iowin->filenameLength * sizeof(TCHAR));
307 _tcsncpy(diskFilename, iowin->filename, iowin->filenameLength);
308 for (i = iowin->filenameLength - 1; i >= 0; i -= 1)
309 {
310 if (diskFilename[i] != _T('.'))
311 continue;
312 _sntprintf(&diskFilename[i], iowin->filenameLength - i, _T(".z%02d"), number_disk + 1);
313 break;
314 }
315 if (i >= 0)
316 ret = win32_open_file_func(opaque, diskFilename, mode);
317 free(diskFilename);
318 return ret;
319 }
320
win32_read_file_func(voidpf opaque,voidpf stream,void * buf,uLong size)321 uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
322 {
323 uLong ret = 0;
324 HANDLE hFile = NULL;
325 if (stream != NULL)
326 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
327
328 if (hFile != NULL)
329 {
330 if (!ReadFile(hFile, buf, size, &ret, NULL))
331 {
332 DWORD dwErr = GetLastError();
333 if (dwErr == ERROR_HANDLE_EOF)
334 dwErr = 0;
335 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
336 }
337 }
338
339 return ret;
340 }
341
win32_write_file_func(voidpf opaque,voidpf stream,const void * buf,uLong size)342 uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
343 {
344 uLong ret = 0;
345 HANDLE hFile = NULL;
346 if (stream != NULL)
347 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
348
349 if (hFile != NULL)
350 {
351 if (!WriteFile(hFile, buf, size, &ret, NULL))
352 {
353 DWORD dwErr = GetLastError();
354 if (dwErr == ERROR_HANDLE_EOF)
355 dwErr = 0;
356 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
357 }
358 }
359
360 return ret;
361 }
362
win32_setfilepointer_internal(HANDLE hFile,LARGE_INTEGER pos,LARGE_INTEGER * newPos,DWORD dwMoveMethod)363 static BOOL win32_setfilepointer_internal(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
364 {
365 #ifdef IOWIN32_USING_WINRT_API
366 return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
367 #else
368 LONG lHigh = pos.HighPart;
369 BOOL ret = TRUE;
370 DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod);
371 if ((dwNewPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
372 ret = FALSE;
373 if ((newPos != NULL) && (ret))
374 {
375 newPos->LowPart = dwNewPos;
376 newPos->HighPart = lHigh;
377 }
378 return ret;
379 #endif
380 }
381
win32_tell_file_func(voidpf opaque,voidpf stream)382 long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
383 {
384 long ret = -1;
385 HANDLE hFile = NULL;
386 if (stream != NULL)
387 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
388 if (hFile != NULL)
389 {
390 LARGE_INTEGER pos;
391 pos.QuadPart = 0;
392 if (!win32_setfilepointer_internal(hFile, pos, &pos, FILE_CURRENT))
393 {
394 DWORD dwErr = GetLastError();
395 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
396 ret = -1;
397 }
398 else
399 ret = (long)pos.LowPart;
400 }
401 return ret;
402 }
403
win32_tell64_file_func(voidpf opaque,voidpf stream)404 ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
405 {
406 ZPOS64_T ret = (ZPOS64_T)-1;
407 HANDLE hFile = NULL;
408 if (stream != NULL)
409 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
410
411 if (hFile)
412 {
413 LARGE_INTEGER pos;
414 pos.QuadPart = 0;
415 if (!win32_setfilepointer_internal(hFile, pos, &pos, FILE_CURRENT))
416 {
417 DWORD dwErr = GetLastError();
418 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
419 ret = (ZPOS64_T)-1;
420 }
421 else
422 ret = pos.QuadPart;
423 }
424 return ret;
425 }
426
427
win32_seek_file_func(voidpf opaque,voidpf stream,uLong offset,int origin)428 long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
429 {
430 DWORD dwMoveMethod = 0xFFFFFFFF;
431 HANDLE hFile = NULL;
432 long ret = -1;
433
434 if (stream != NULL)
435 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
436
437 switch (origin)
438 {
439 case ZLIB_FILEFUNC_SEEK_CUR:
440 dwMoveMethod = FILE_CURRENT;
441 break;
442 case ZLIB_FILEFUNC_SEEK_END:
443 dwMoveMethod = FILE_END;
444 break;
445 case ZLIB_FILEFUNC_SEEK_SET:
446 dwMoveMethod = FILE_BEGIN;
447 break;
448 default:
449 return -1;
450 }
451
452 if (hFile != NULL)
453 {
454 LARGE_INTEGER pos;
455 pos.QuadPart = offset;
456 if (!win32_setfilepointer_internal(hFile, pos, NULL, dwMoveMethod))
457 {
458 DWORD dwErr = GetLastError();
459 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
460 ret = -1;
461 }
462 else
463 ret = 0;
464 }
465 return ret;
466 }
467
win32_seek64_file_func(voidpf opaque,voidpf stream,ZPOS64_T offset,int origin)468 long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
469 {
470 DWORD dwMoveMethod = 0xFFFFFFFF;
471 HANDLE hFile = NULL;
472 long ret = -1;
473
474 if (stream != NULL)
475 hFile = ((WIN32FILE_IOWIN*)stream)->hf;
476
477 switch (origin)
478 {
479 case ZLIB_FILEFUNC_SEEK_CUR:
480 dwMoveMethod = FILE_CURRENT;
481 break;
482 case ZLIB_FILEFUNC_SEEK_END:
483 dwMoveMethod = FILE_END;
484 break;
485 case ZLIB_FILEFUNC_SEEK_SET:
486 dwMoveMethod = FILE_BEGIN;
487 break;
488 default:
489 return -1;
490 }
491
492 if (hFile)
493 {
494 LARGE_INTEGER pos;
495 pos.QuadPart = offset;
496 if (!win32_setfilepointer_internal(hFile, pos, NULL, dwMoveMethod))
497 {
498 DWORD dwErr = GetLastError();
499 ((WIN32FILE_IOWIN*)stream)->error = (int)dwErr;
500 ret = -1;
501 }
502 else
503 ret = 0;
504 }
505 return ret;
506 }
507
win32_close_file_func(voidpf opaque,voidpf stream)508 int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
509 {
510 WIN32FILE_IOWIN* iowin = NULL;
511 int ret = -1;
512
513 if (stream == NULL)
514 return ret;
515 iowin = ((WIN32FILE_IOWIN*)stream);
516 if (iowin->filename != NULL)
517 free(iowin->filename);
518 if (iowin->hf != NULL)
519 {
520 CloseHandle(iowin->hf);
521 ret=0;
522 }
523 free(stream);
524 return ret;
525 }
526
win32_error_file_func(voidpf opaque,voidpf stream)527 int ZCALLBACK win32_error_file_func (voidpf opaque, voidpf stream)
528 {
529 int ret = -1;
530 if (stream == NULL)
531 return ret;
532 ret = ((WIN32FILE_IOWIN*)stream)->error;
533 return ret;
534 }
535
fill_win32_filefunc(zlib_filefunc_def * pzlib_filefunc_def)536 void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
537 {
538 pzlib_filefunc_def->zopen_file = win32_open_file_func;
539 pzlib_filefunc_def->zopendisk_file = win32_opendisk_file_func;
540 pzlib_filefunc_def->zread_file = win32_read_file_func;
541 pzlib_filefunc_def->zwrite_file = win32_write_file_func;
542 pzlib_filefunc_def->ztell_file = win32_tell_file_func;
543 pzlib_filefunc_def->zseek_file = win32_seek_file_func;
544 pzlib_filefunc_def->zclose_file = win32_close_file_func;
545 pzlib_filefunc_def->zerror_file = win32_error_file_func;
546 pzlib_filefunc_def->opaque = NULL;
547 }
548
fill_win32_filefunc64(zlib_filefunc64_def * pzlib_filefunc_def)549 void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
550 {
551 pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
552 pzlib_filefunc_def->zopendisk64_file = win32_opendisk64_file_func;
553 pzlib_filefunc_def->zread_file = win32_read_file_func;
554 pzlib_filefunc_def->zwrite_file = win32_write_file_func;
555 pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
556 pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
557 pzlib_filefunc_def->zclose_file = win32_close_file_func;
558 pzlib_filefunc_def->zerror_file = win32_error_file_func;
559 pzlib_filefunc_def->opaque = NULL;
560 }
561
fill_win32_filefunc64A(zlib_filefunc64_def * pzlib_filefunc_def)562 void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
563 {
564 pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
565 pzlib_filefunc_def->zopendisk64_file = win32_opendisk64_file_funcA;
566 pzlib_filefunc_def->zread_file = win32_read_file_func;
567 pzlib_filefunc_def->zwrite_file = win32_write_file_func;
568 pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
569 pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
570 pzlib_filefunc_def->zclose_file = win32_close_file_func;
571 pzlib_filefunc_def->zerror_file = win32_error_file_func;
572 pzlib_filefunc_def->opaque = NULL;
573 }
574
fill_win32_filefunc64W(zlib_filefunc64_def * pzlib_filefunc_def)575 void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
576 {
577 pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
578 pzlib_filefunc_def->zopendisk64_file = win32_opendisk64_file_funcW;
579 pzlib_filefunc_def->zread_file = win32_read_file_func;
580 pzlib_filefunc_def->zwrite_file = win32_write_file_func;
581 pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
582 pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
583 pzlib_filefunc_def->zclose_file = win32_close_file_func;
584 pzlib_filefunc_def->zerror_file = win32_error_file_func;
585 pzlib_filefunc_def->opaque = NULL;
586 }
587
588 #endif // WIN32
589