xlsxwriter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +40 -0
- data/ext/xlsxwriter/chart.c +105 -0
- data/ext/xlsxwriter/chart.h +27 -0
- data/ext/xlsxwriter/extconf.rb +14 -0
- data/ext/xlsxwriter/format.c +67 -0
- data/ext/xlsxwriter/format.h +9 -0
- data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
- data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
- data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
- data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
- data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/workbook.c +257 -0
- data/ext/xlsxwriter/workbook.h +42 -0
- data/ext/xlsxwriter/workbook_properties.c +103 -0
- data/ext/xlsxwriter/workbook_properties.h +10 -0
- data/ext/xlsxwriter/worksheet.c +1064 -0
- data/ext/xlsxwriter/worksheet.h +74 -0
- data/ext/xlsxwriter/xlsxwriter.c +239 -0
- data/lib/xlsxwriter.rb +6 -0
- data/lib/xlsxwriter/version.rb +3 -0
- data/lib/xlsxwriter/worksheet.rb +72 -0
- data/test/run-test.rb +11 -0
- data/test/support/xlsx_comparable.rb +109 -0
- data/test/test-array-formula.rb +33 -0
- data/test/test-autofilter.rb +70 -0
- data/test/test-chart-area.rb +25 -0
- data/test/test-data.rb +65 -0
- data/test/test-default-row.rb +25 -0
- data/test/test-defined-name.rb +46 -0
- data/test/test-escapes.rb +33 -0
- data/test/test-fit-to-pages.rb +21 -0
- data/test/test-formatting.rb +137 -0
- data/test/test-gridlines.rb +15 -0
- data/test/test-hyperlink.rb +67 -0
- data/test/test-image.rb +84 -0
- data/test/test-merge-range.rb +18 -0
- data/test/test-misc.rb +29 -0
- data/test/test-optimize.rb +32 -0
- data/test/test-page-breaks.rb +13 -0
- data/test/test-page-setup.rb +28 -0
- data/test/test-panes.rb +45 -0
- data/test/test-print-area.rb +19 -0
- data/test/test-print-options.rb +61 -0
- data/test/test-print-scale.rb +12 -0
- data/test/test-properties.rb +51 -0
- data/test/test-protect.rb +27 -0
- data/test/test-repeat.rb +23 -0
- data/test/test-row-col-format.rb +35 -0
- data/test/test-set-selection.rb +13 -0
- data/test/test-set-start-page.rb +13 -0
- data/test/test-simple.rb +62 -0
- data/test/test-types.rb +17 -0
- data/test/xlsx-func-testcase.rb +36 -0
- metadata +228 -0
@@ -0,0 +1,456 @@
|
|
1
|
+
/* iowin32.c -- IO base function header for compress/uncompress .zip
|
2
|
+
Version 1.1, February 14h, 2010
|
3
|
+
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
4
|
+
|
5
|
+
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
6
|
+
|
7
|
+
Modifications for Zip64 support
|
8
|
+
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
9
|
+
|
10
|
+
For more info read MiniZip_info.txt
|
11
|
+
|
12
|
+
*/
|
13
|
+
|
14
|
+
#include <stdlib.h>
|
15
|
+
|
16
|
+
#include "zlib.h"
|
17
|
+
#include "ioapi.h"
|
18
|
+
#include "iowin32.h"
|
19
|
+
|
20
|
+
#ifndef INVALID_HANDLE_VALUE
|
21
|
+
#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#ifndef INVALID_SET_FILE_POINTER
|
25
|
+
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
26
|
+
#endif
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
|
31
|
+
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
32
|
+
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
33
|
+
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
|
34
|
+
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
35
|
+
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
|
36
|
+
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
|
37
|
+
|
38
|
+
typedef struct
|
39
|
+
{
|
40
|
+
HANDLE hf;
|
41
|
+
int error;
|
42
|
+
} WIN32FILE_IOWIN;
|
43
|
+
|
44
|
+
|
45
|
+
static void win32_translate_open_mode(int mode,
|
46
|
+
DWORD* lpdwDesiredAccess,
|
47
|
+
DWORD* lpdwCreationDisposition,
|
48
|
+
DWORD* lpdwShareMode,
|
49
|
+
DWORD* lpdwFlagsAndAttributes)
|
50
|
+
{
|
51
|
+
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
|
52
|
+
|
53
|
+
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
54
|
+
{
|
55
|
+
*lpdwDesiredAccess = GENERIC_READ;
|
56
|
+
*lpdwCreationDisposition = OPEN_EXISTING;
|
57
|
+
*lpdwShareMode = FILE_SHARE_READ;
|
58
|
+
}
|
59
|
+
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
60
|
+
{
|
61
|
+
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
62
|
+
*lpdwCreationDisposition = OPEN_EXISTING;
|
63
|
+
}
|
64
|
+
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
65
|
+
{
|
66
|
+
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
67
|
+
*lpdwCreationDisposition = CREATE_ALWAYS;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
static voidpf win32_build_iowin(HANDLE hFile)
|
72
|
+
{
|
73
|
+
voidpf ret=NULL;
|
74
|
+
|
75
|
+
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
|
76
|
+
{
|
77
|
+
WIN32FILE_IOWIN w32fiow;
|
78
|
+
w32fiow.hf = hFile;
|
79
|
+
w32fiow.error = 0;
|
80
|
+
ret = malloc(sizeof(WIN32FILE_IOWIN));
|
81
|
+
|
82
|
+
if (ret==NULL)
|
83
|
+
CloseHandle(hFile);
|
84
|
+
else
|
85
|
+
*((WIN32FILE_IOWIN*)ret) = w32fiow;
|
86
|
+
}
|
87
|
+
return ret;
|
88
|
+
}
|
89
|
+
|
90
|
+
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
|
91
|
+
{
|
92
|
+
const char* mode_fopen = NULL;
|
93
|
+
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
94
|
+
HANDLE hFile = NULL;
|
95
|
+
|
96
|
+
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
97
|
+
|
98
|
+
#ifdef IOWIN32_USING_WINRT_API
|
99
|
+
#ifdef UNICODE
|
100
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
101
|
+
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
102
|
+
#else
|
103
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
104
|
+
{
|
105
|
+
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
106
|
+
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
107
|
+
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
108
|
+
}
|
109
|
+
#endif
|
110
|
+
#else
|
111
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
112
|
+
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
113
|
+
#endif
|
114
|
+
|
115
|
+
return win32_build_iowin(hFile);
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
|
120
|
+
{
|
121
|
+
const char* mode_fopen = NULL;
|
122
|
+
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
123
|
+
HANDLE hFile = NULL;
|
124
|
+
|
125
|
+
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
126
|
+
|
127
|
+
#ifdef IOWIN32_USING_WINRT_API
|
128
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
129
|
+
{
|
130
|
+
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
131
|
+
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
132
|
+
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
133
|
+
}
|
134
|
+
#else
|
135
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
136
|
+
hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
137
|
+
#endif
|
138
|
+
|
139
|
+
return win32_build_iowin(hFile);
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
|
144
|
+
{
|
145
|
+
const char* mode_fopen = NULL;
|
146
|
+
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
147
|
+
HANDLE hFile = NULL;
|
148
|
+
|
149
|
+
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
150
|
+
|
151
|
+
#ifdef IOWIN32_USING_WINRT_API
|
152
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
153
|
+
hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
|
154
|
+
#else
|
155
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
156
|
+
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
157
|
+
#endif
|
158
|
+
|
159
|
+
return win32_build_iowin(hFile);
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
|
164
|
+
{
|
165
|
+
const char* mode_fopen = NULL;
|
166
|
+
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
167
|
+
HANDLE hFile = NULL;
|
168
|
+
|
169
|
+
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
170
|
+
|
171
|
+
#ifdef IOWIN32_USING_WINRT_API
|
172
|
+
#ifdef UNICODE
|
173
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
174
|
+
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
175
|
+
#else
|
176
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
177
|
+
{
|
178
|
+
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
179
|
+
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
180
|
+
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
181
|
+
}
|
182
|
+
#endif
|
183
|
+
#else
|
184
|
+
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
185
|
+
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
186
|
+
#endif
|
187
|
+
|
188
|
+
return win32_build_iowin(hFile);
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
|
193
|
+
{
|
194
|
+
uLong ret=0;
|
195
|
+
HANDLE hFile = NULL;
|
196
|
+
if (stream!=NULL)
|
197
|
+
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
198
|
+
|
199
|
+
if (hFile != NULL)
|
200
|
+
{
|
201
|
+
if (!ReadFile(hFile, buf, size, &ret, NULL))
|
202
|
+
{
|
203
|
+
DWORD dwErr = GetLastError();
|
204
|
+
if (dwErr == ERROR_HANDLE_EOF)
|
205
|
+
dwErr = 0;
|
206
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
return ret;
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
|
215
|
+
{
|
216
|
+
uLong ret=0;
|
217
|
+
HANDLE hFile = NULL;
|
218
|
+
if (stream!=NULL)
|
219
|
+
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
220
|
+
|
221
|
+
if (hFile != NULL)
|
222
|
+
{
|
223
|
+
if (!WriteFile(hFile, buf, size, &ret, NULL))
|
224
|
+
{
|
225
|
+
DWORD dwErr = GetLastError();
|
226
|
+
if (dwErr == ERROR_HANDLE_EOF)
|
227
|
+
dwErr = 0;
|
228
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
return ret;
|
233
|
+
}
|
234
|
+
|
235
|
+
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
|
236
|
+
{
|
237
|
+
#ifdef IOWIN32_USING_WINRT_API
|
238
|
+
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
|
239
|
+
#else
|
240
|
+
LONG lHigh = pos.HighPart;
|
241
|
+
DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod);
|
242
|
+
BOOL fOk = TRUE;
|
243
|
+
if (dwNewPos == 0xFFFFFFFF)
|
244
|
+
if (GetLastError() != NO_ERROR)
|
245
|
+
fOk = FALSE;
|
246
|
+
if ((newPos != NULL) && (fOk))
|
247
|
+
{
|
248
|
+
newPos->LowPart = dwNewPos;
|
249
|
+
newPos->HighPart = lHigh;
|
250
|
+
}
|
251
|
+
return fOk;
|
252
|
+
#endif
|
253
|
+
}
|
254
|
+
|
255
|
+
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
256
|
+
{
|
257
|
+
long ret=-1;
|
258
|
+
HANDLE hFile = NULL;
|
259
|
+
if (stream!=NULL)
|
260
|
+
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
261
|
+
if (hFile != NULL)
|
262
|
+
{
|
263
|
+
LARGE_INTEGER pos;
|
264
|
+
pos.QuadPart = 0;
|
265
|
+
|
266
|
+
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
267
|
+
{
|
268
|
+
DWORD dwErr = GetLastError();
|
269
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
270
|
+
ret = -1;
|
271
|
+
}
|
272
|
+
else
|
273
|
+
ret=(long)pos.LowPart;
|
274
|
+
}
|
275
|
+
return ret;
|
276
|
+
}
|
277
|
+
|
278
|
+
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
279
|
+
{
|
280
|
+
ZPOS64_T ret= (ZPOS64_T)-1;
|
281
|
+
HANDLE hFile = NULL;
|
282
|
+
if (stream!=NULL)
|
283
|
+
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
284
|
+
|
285
|
+
if (hFile)
|
286
|
+
{
|
287
|
+
LARGE_INTEGER pos;
|
288
|
+
pos.QuadPart = 0;
|
289
|
+
|
290
|
+
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
291
|
+
{
|
292
|
+
DWORD dwErr = GetLastError();
|
293
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
294
|
+
ret = (ZPOS64_T)-1;
|
295
|
+
}
|
296
|
+
else
|
297
|
+
ret=pos.QuadPart;
|
298
|
+
}
|
299
|
+
return ret;
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
|
304
|
+
{
|
305
|
+
DWORD dwMoveMethod=0xFFFFFFFF;
|
306
|
+
HANDLE hFile = NULL;
|
307
|
+
|
308
|
+
long ret=-1;
|
309
|
+
if (stream!=NULL)
|
310
|
+
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
311
|
+
switch (origin)
|
312
|
+
{
|
313
|
+
case ZLIB_FILEFUNC_SEEK_CUR :
|
314
|
+
dwMoveMethod = FILE_CURRENT;
|
315
|
+
break;
|
316
|
+
case ZLIB_FILEFUNC_SEEK_END :
|
317
|
+
dwMoveMethod = FILE_END;
|
318
|
+
break;
|
319
|
+
case ZLIB_FILEFUNC_SEEK_SET :
|
320
|
+
dwMoveMethod = FILE_BEGIN;
|
321
|
+
break;
|
322
|
+
default: return -1;
|
323
|
+
}
|
324
|
+
|
325
|
+
if (hFile != NULL)
|
326
|
+
{
|
327
|
+
LARGE_INTEGER pos;
|
328
|
+
pos.QuadPart = offset;
|
329
|
+
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
|
330
|
+
{
|
331
|
+
DWORD dwErr = GetLastError();
|
332
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
333
|
+
ret = -1;
|
334
|
+
}
|
335
|
+
else
|
336
|
+
ret=0;
|
337
|
+
}
|
338
|
+
return ret;
|
339
|
+
}
|
340
|
+
|
341
|
+
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
|
342
|
+
{
|
343
|
+
DWORD dwMoveMethod=0xFFFFFFFF;
|
344
|
+
HANDLE hFile = NULL;
|
345
|
+
long ret=-1;
|
346
|
+
|
347
|
+
if (stream!=NULL)
|
348
|
+
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
349
|
+
|
350
|
+
switch (origin)
|
351
|
+
{
|
352
|
+
case ZLIB_FILEFUNC_SEEK_CUR :
|
353
|
+
dwMoveMethod = FILE_CURRENT;
|
354
|
+
break;
|
355
|
+
case ZLIB_FILEFUNC_SEEK_END :
|
356
|
+
dwMoveMethod = FILE_END;
|
357
|
+
break;
|
358
|
+
case ZLIB_FILEFUNC_SEEK_SET :
|
359
|
+
dwMoveMethod = FILE_BEGIN;
|
360
|
+
break;
|
361
|
+
default: return -1;
|
362
|
+
}
|
363
|
+
|
364
|
+
if (hFile)
|
365
|
+
{
|
366
|
+
LARGE_INTEGER pos;
|
367
|
+
pos.QuadPart = offset;
|
368
|
+
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
|
369
|
+
{
|
370
|
+
DWORD dwErr = GetLastError();
|
371
|
+
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
372
|
+
ret = -1;
|
373
|
+
}
|
374
|
+
else
|
375
|
+
ret=0;
|
376
|
+
}
|
377
|
+
return ret;
|
378
|
+
}
|
379
|
+
|
380
|
+
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
381
|
+
{
|
382
|
+
int ret=-1;
|
383
|
+
|
384
|
+
if (stream!=NULL)
|
385
|
+
{
|
386
|
+
HANDLE hFile;
|
387
|
+
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
388
|
+
if (hFile != NULL)
|
389
|
+
{
|
390
|
+
CloseHandle(hFile);
|
391
|
+
ret=0;
|
392
|
+
}
|
393
|
+
free(stream);
|
394
|
+
}
|
395
|
+
return ret;
|
396
|
+
}
|
397
|
+
|
398
|
+
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
399
|
+
{
|
400
|
+
int ret=-1;
|
401
|
+
if (stream!=NULL)
|
402
|
+
{
|
403
|
+
ret = ((WIN32FILE_IOWIN*)stream) -> error;
|
404
|
+
}
|
405
|
+
return ret;
|
406
|
+
}
|
407
|
+
|
408
|
+
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
409
|
+
{
|
410
|
+
pzlib_filefunc_def->zopen_file = win32_open_file_func;
|
411
|
+
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
412
|
+
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
413
|
+
pzlib_filefunc_def->ztell_file = win32_tell_file_func;
|
414
|
+
pzlib_filefunc_def->zseek_file = win32_seek_file_func;
|
415
|
+
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
416
|
+
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
417
|
+
pzlib_filefunc_def->opaque = NULL;
|
418
|
+
}
|
419
|
+
|
420
|
+
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
421
|
+
{
|
422
|
+
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
|
423
|
+
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
424
|
+
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
425
|
+
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
426
|
+
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
427
|
+
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
428
|
+
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
429
|
+
pzlib_filefunc_def->opaque = NULL;
|
430
|
+
}
|
431
|
+
|
432
|
+
|
433
|
+
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
434
|
+
{
|
435
|
+
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
|
436
|
+
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
437
|
+
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
438
|
+
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
439
|
+
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
440
|
+
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
441
|
+
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
442
|
+
pzlib_filefunc_def->opaque = NULL;
|
443
|
+
}
|
444
|
+
|
445
|
+
|
446
|
+
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
|
447
|
+
{
|
448
|
+
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
|
449
|
+
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
450
|
+
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
451
|
+
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
452
|
+
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
453
|
+
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
454
|
+
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
455
|
+
pzlib_filefunc_def->opaque = NULL;
|
456
|
+
}
|