2
Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
4
See the accompanying file LICENSE, version 2009-Jan-02 or later
5
(the contents of which are also included in zip.h) for terms of use.
6
If, for some reason, all these files are missing, the Info-ZIP license
7
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9
/*---------------------------------------------------------------------------
11
win32/win32i64.c - UnZip 6
13
64-bit filesize support for WIN32 Zip and UnZip.
14
---------------------------------------------------------------------------*/
18
/* --------------------------------------------------- */
21
* Initial functions by E. Gordon and R. Nausedat
24
* These implement 64-bit file support for Windows. The
25
* defines and headers are in win32/osdep.h.
27
* These moved from win32.c by Mike White to avoid conflicts
28
* in WiZ of same name functions in UnZip and Zip libraries.
32
#if defined(LARGE_FILE_SUPPORT) && !defined(__CYGWIN__)
33
# ifdef USE_STRM_INPUT
36
/* 64-bit buffered ftello
38
* Win32 does not provide a 64-bit buffered
39
* ftell (in the published api anyway) so below provides
40
* hopefully close version.
41
* We have not gotten _telli64 to work with buffered
42
* streams. Below cheats by using fgetpos improperly and
43
* may not work on other ports.
46
zoff_t zftello(stream)
51
if (fgetpos(stream, &fpos) != 0) {
57
# endif /* ndef zftello */
61
/* 64-bit buffered fseeko
63
* Win32 does not provide a 64-bit buffered
64
* fseeko, so use _lseeki64 and fflush. Note
65
* that SEEK_CUR can lose track of location
66
* if fflush is done between the last buffered
70
int zfseeko(stream, offset, origin)
76
/* fseek() or its replacements are supposed to clear the eof status
77
of the stream. fflush() and _lseeki64() do not touch the stream's
78
eof flag, so we have to do it manually. */
79
#if ((defined(_MSC_VER) && (_MSC_VER >= 1200)) || \
80
(defined(__MINGW32__) && defined(__MSVCRT_VERSION__)))
81
/* For the MSC environment (VS 6 or higher), and for recent releases of
82
the MinGW environment, we "know" the internals of the FILE structure.
83
So, we can clear just the EOF bit of the status flag. */
84
stream->_flag &= ~_IOEOF;
86
/* Unfortunately, there is no standard "cleareof()" function, so we have
87
to use clearerr(). This has the unwanted side effect of clearing the
88
ferror() state as well. */
92
if (origin == SEEK_CUR) {
93
/* instead of synching up lseek easier just to figure and
94
use an absolute offset */
95
offset += zftello(stream);
99
if (_lseeki64(fileno(stream), offset, origin) == (zoff_t)-1L) {
105
# endif /* ndef fseeko */
106
# endif /* USE_STRM_INPUT */
107
#endif /* Win32 LARGE_FILE_SUPPORT */
110
FILE* zfopen(filename, mode)
111
const char *filename;
116
fTemp = fopen(filename, mode);
120
/* sorry, could not make VC60 and its rtl work properly without setting the
121
* file buffer to NULL. the problem seems to be _telli64 which seems to
122
* return the max stream position, comments are welcome
129
/* --------------------------------------------------- */