minizip.c revision 1.1.1.4 1 1.1 christos /*
2 1.1 christos minizip.c
3 1.1.1.2 christos Version 1.1, February 14h, 2010
4 1.1.1.2 christos sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
5 1.1.1.2 christos
6 1.1.1.2 christos Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
7 1.1.1.2 christos
8 1.1.1.2 christos Modifications of Unzip for Zip64
9 1.1.1.2 christos Copyright (C) 2007-2008 Even Rouault
10 1.1 christos
11 1.1.1.2 christos Modifications for Zip64 support on both zip and unzip
12 1.1.1.2 christos Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
13 1.1 christos */
14 1.1 christos
15 1.1.1.2 christos
16 1.1.1.2 christos #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
17 1.1.1.2 christos #ifndef __USE_FILE_OFFSET64
18 1.1.1.2 christos #define __USE_FILE_OFFSET64
19 1.1.1.2 christos #endif
20 1.1.1.2 christos #ifndef __USE_LARGEFILE64
21 1.1.1.2 christos #define __USE_LARGEFILE64
22 1.1.1.2 christos #endif
23 1.1.1.2 christos #ifndef _LARGEFILE64_SOURCE
24 1.1.1.2 christos #define _LARGEFILE64_SOURCE
25 1.1.1.2 christos #endif
26 1.1.1.2 christos #ifndef _FILE_OFFSET_BIT
27 1.1.1.2 christos #define _FILE_OFFSET_BIT 64
28 1.1.1.2 christos #endif
29 1.1.1.2 christos #endif
30 1.1.1.2 christos
31 1.1.1.4 christos #if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
32 1.1.1.2 christos // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
33 1.1.1.2 christos #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
34 1.1.1.2 christos #define FTELLO_FUNC(stream) ftello(stream)
35 1.1.1.2 christos #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
36 1.1.1.2 christos #else
37 1.1.1.2 christos #define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
38 1.1.1.2 christos #define FTELLO_FUNC(stream) ftello64(stream)
39 1.1.1.2 christos #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
40 1.1.1.2 christos #endif
41 1.1.1.2 christos
42 1.1.1.2 christos
43 1.1.1.2 christos
44 1.1 christos #include <stdio.h>
45 1.1 christos #include <stdlib.h>
46 1.1 christos #include <string.h>
47 1.1 christos #include <time.h>
48 1.1 christos #include <errno.h>
49 1.1 christos #include <fcntl.h>
50 1.1 christos
51 1.1.1.2 christos #ifdef _WIN32
52 1.1.1.2 christos # include <direct.h>
53 1.1.1.2 christos # include <io.h>
54 1.1.1.2 christos #else
55 1.1 christos # include <unistd.h>
56 1.1 christos # include <utime.h>
57 1.1 christos # include <sys/types.h>
58 1.1 christos # include <sys/stat.h>
59 1.1 christos #endif
60 1.1 christos
61 1.1 christos #include "zip.h"
62 1.1 christos
63 1.1.1.2 christos #ifdef _WIN32
64 1.1.1.2 christos #define USEWIN32IOAPI
65 1.1.1.2 christos #include "iowin32.h"
66 1.1 christos #endif
67 1.1 christos
68 1.1 christos
69 1.1 christos
70 1.1 christos #define WRITEBUFFERSIZE (16384)
71 1.1 christos #define MAXFILENAME (256)
72 1.1 christos
73 1.1.1.2 christos #ifdef _WIN32
74 1.1.1.4 christos /* f: name of file to get info on, tmzip: return value: access,
75 1.1.1.4 christos modification and creation times, dt: dostime */
76 1.1.1.4 christos static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
77 1.1 christos int ret = 0;
78 1.1 christos {
79 1.1 christos FILETIME ftLocal;
80 1.1 christos HANDLE hFind;
81 1.1.1.2 christos WIN32_FIND_DATAA ff32;
82 1.1 christos
83 1.1.1.2 christos hFind = FindFirstFileA(f,&ff32);
84 1.1 christos if (hFind != INVALID_HANDLE_VALUE)
85 1.1 christos {
86 1.1 christos FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
87 1.1 christos FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
88 1.1 christos FindClose(hFind);
89 1.1 christos ret = 1;
90 1.1 christos }
91 1.1 christos }
92 1.1 christos return ret;
93 1.1 christos }
94 1.1 christos #else
95 1.1.1.3 christos #if defined(unix) || defined(__APPLE__)
96 1.1.1.4 christos /* f: name of file to get info on, tmzip: return value: access,
97 1.1.1.4 christos modification and creation times, dt: dostime */
98 1.1.1.4 christos static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
99 1.1.1.3 christos (void)dt;
100 1.1 christos int ret=0;
101 1.1 christos struct stat s; /* results of stat() */
102 1.1 christos struct tm* filedate;
103 1.1 christos time_t tm_t=0;
104 1.1 christos
105 1.1 christos if (strcmp(f,"-")!=0)
106 1.1 christos {
107 1.1 christos char name[MAXFILENAME+1];
108 1.1.1.3 christos size_t len = strlen(f);
109 1.1 christos if (len > MAXFILENAME)
110 1.1 christos len = MAXFILENAME;
111 1.1 christos
112 1.1 christos strncpy(name, f,MAXFILENAME-1);
113 1.1.1.4 christos /* strncpy doesn't append the trailing NULL, of the string is too long. */
114 1.1 christos name[ MAXFILENAME ] = '\0';
115 1.1 christos
116 1.1 christos if (name[len - 1] == '/')
117 1.1 christos name[len - 1] = '\0';
118 1.1 christos /* not all systems allow stat'ing a file with / appended */
119 1.1 christos if (stat(name,&s)==0)
120 1.1 christos {
121 1.1 christos tm_t = s.st_mtime;
122 1.1 christos ret = 1;
123 1.1 christos }
124 1.1 christos }
125 1.1 christos filedate = localtime(&tm_t);
126 1.1 christos
127 1.1 christos tmzip->tm_sec = filedate->tm_sec;
128 1.1 christos tmzip->tm_min = filedate->tm_min;
129 1.1 christos tmzip->tm_hour = filedate->tm_hour;
130 1.1 christos tmzip->tm_mday = filedate->tm_mday;
131 1.1 christos tmzip->tm_mon = filedate->tm_mon ;
132 1.1 christos tmzip->tm_year = filedate->tm_year;
133 1.1 christos
134 1.1 christos return ret;
135 1.1 christos }
136 1.1 christos #else
137 1.1.1.4 christos /* f: name of file to get info on, tmzip: return value: access,
138 1.1.1.4 christos modification and creation times, dt: dostime */
139 1.1.1.4 christos static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
140 1.1.1.4 christos (void)f;
141 1.1.1.4 christos (void)tmzip;
142 1.1.1.4 christos (void)dt;
143 1.1 christos return 0;
144 1.1 christos }
145 1.1 christos #endif
146 1.1 christos #endif
147 1.1 christos
148 1.1 christos
149 1.1 christos
150 1.1 christos
151 1.1.1.4 christos static int check_exist_file(const char* filename) {
152 1.1 christos FILE* ftestexist;
153 1.1 christos int ret = 1;
154 1.1.1.2 christos ftestexist = FOPEN_FUNC(filename,"rb");
155 1.1 christos if (ftestexist==NULL)
156 1.1 christos ret = 0;
157 1.1 christos else
158 1.1 christos fclose(ftestexist);
159 1.1 christos return ret;
160 1.1 christos }
161 1.1 christos
162 1.1.1.4 christos static void do_banner(void) {
163 1.1.1.2 christos printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
164 1.1.1.2 christos printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
165 1.1 christos }
166 1.1 christos
167 1.1.1.4 christos static void do_help(void) {
168 1.1.1.2 christos printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
169 1.1 christos " -o Overwrite existing file.zip\n" \
170 1.1 christos " -a Append to existing file.zip\n" \
171 1.1 christos " -0 Store only\n" \
172 1.1 christos " -1 Compress faster\n" \
173 1.1.1.2 christos " -9 Compress better\n\n" \
174 1.1.1.2 christos " -j exclude path. store only the file name.\n\n");
175 1.1 christos }
176 1.1 christos
177 1.1 christos /* calculate the CRC32 of a file,
178 1.1 christos because to encrypt a file, we need known the CRC32 of the file before */
179 1.1.1.4 christos static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
180 1.1 christos unsigned long calculate_crc=0;
181 1.1 christos int err=ZIP_OK;
182 1.1.1.2 christos FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
183 1.1.1.2 christos
184 1.1 christos unsigned long size_read = 0;
185 1.1.1.3 christos /* unsigned long total_read = 0; */
186 1.1 christos if (fin==NULL)
187 1.1 christos {
188 1.1 christos err = ZIP_ERRNO;
189 1.1 christos }
190 1.1 christos
191 1.1 christos if (err == ZIP_OK)
192 1.1 christos do
193 1.1 christos {
194 1.1 christos err = ZIP_OK;
195 1.1.1.3 christos size_read = fread(buf,1,size_buf,fin);
196 1.1 christos if (size_read < size_buf)
197 1.1 christos if (feof(fin)==0)
198 1.1 christos {
199 1.1 christos printf("error in reading %s\n",filenameinzip);
200 1.1 christos err = ZIP_ERRNO;
201 1.1 christos }
202 1.1 christos
203 1.1 christos if (size_read>0)
204 1.1.1.3 christos calculate_crc = crc32_z(calculate_crc,buf,size_read);
205 1.1.1.3 christos /* total_read += size_read; */
206 1.1 christos
207 1.1 christos } while ((err == ZIP_OK) && (size_read>0));
208 1.1 christos
209 1.1 christos if (fin)
210 1.1 christos fclose(fin);
211 1.1 christos
212 1.1 christos *result_crc=calculate_crc;
213 1.1.1.2 christos printf("file %s crc %lx\n", filenameinzip, calculate_crc);
214 1.1 christos return err;
215 1.1 christos }
216 1.1 christos
217 1.1.1.4 christos static int isLargeFile(const char* filename) {
218 1.1.1.2 christos int largeFile = 0;
219 1.1.1.2 christos ZPOS64_T pos = 0;
220 1.1.1.2 christos FILE* pFile = FOPEN_FUNC(filename, "rb");
221 1.1.1.2 christos
222 1.1.1.2 christos if(pFile != NULL)
223 1.1.1.2 christos {
224 1.1.1.3 christos FSEEKO_FUNC(pFile, 0, SEEK_END);
225 1.1.1.3 christos pos = (ZPOS64_T)FTELLO_FUNC(pFile);
226 1.1.1.2 christos
227 1.1.1.4 christos printf("File : %s is %llu bytes\n", filename, pos);
228 1.1.1.2 christos
229 1.1.1.2 christos if(pos >= 0xffffffff)
230 1.1.1.2 christos largeFile = 1;
231 1.1.1.2 christos
232 1.1.1.2 christos fclose(pFile);
233 1.1.1.2 christos }
234 1.1.1.2 christos
235 1.1.1.2 christos return largeFile;
236 1.1.1.2 christos }
237 1.1.1.2 christos
238 1.1.1.4 christos int main(int argc, char *argv[]) {
239 1.1 christos int i;
240 1.1 christos int opt_overwrite=0;
241 1.1 christos int opt_compress_level=Z_DEFAULT_COMPRESSION;
242 1.1.1.2 christos int opt_exclude_path=0;
243 1.1 christos int zipfilenamearg = 0;
244 1.1 christos char filename_try[MAXFILENAME+16];
245 1.1 christos int zipok;
246 1.1 christos int err=0;
247 1.1.1.3 christos size_t size_buf=0;
248 1.1 christos void* buf=NULL;
249 1.1 christos const char* password=NULL;
250 1.1 christos
251 1.1 christos
252 1.1 christos do_banner();
253 1.1 christos if (argc==1)
254 1.1 christos {
255 1.1 christos do_help();
256 1.1 christos return 0;
257 1.1 christos }
258 1.1 christos else
259 1.1 christos {
260 1.1 christos for (i=1;i<argc;i++)
261 1.1 christos {
262 1.1 christos if ((*argv[i])=='-')
263 1.1 christos {
264 1.1 christos const char *p=argv[i]+1;
265 1.1 christos
266 1.1 christos while ((*p)!='\0')
267 1.1 christos {
268 1.1.1.3 christos char c=*(p++);
269 1.1 christos if ((c=='o') || (c=='O'))
270 1.1 christos opt_overwrite = 1;
271 1.1 christos if ((c=='a') || (c=='A'))
272 1.1 christos opt_overwrite = 2;
273 1.1 christos if ((c>='0') && (c<='9'))
274 1.1 christos opt_compress_level = c-'0';
275 1.1.1.2 christos if ((c=='j') || (c=='J'))
276 1.1.1.2 christos opt_exclude_path = 1;
277 1.1 christos
278 1.1 christos if (((c=='p') || (c=='P')) && (i+1<argc))
279 1.1 christos {
280 1.1 christos password=argv[i+1];
281 1.1 christos i++;
282 1.1 christos }
283 1.1 christos }
284 1.1 christos }
285 1.1 christos else
286 1.1.1.2 christos {
287 1.1 christos if (zipfilenamearg == 0)
288 1.1.1.2 christos {
289 1.1 christos zipfilenamearg = i ;
290 1.1.1.2 christos }
291 1.1.1.2 christos }
292 1.1 christos }
293 1.1 christos }
294 1.1 christos
295 1.1 christos size_buf = WRITEBUFFERSIZE;
296 1.1 christos buf = (void*)malloc(size_buf);
297 1.1 christos if (buf==NULL)
298 1.1 christos {
299 1.1 christos printf("Error allocating memory\n");
300 1.1 christos return ZIP_INTERNALERROR;
301 1.1 christos }
302 1.1 christos
303 1.1 christos if (zipfilenamearg==0)
304 1.1.1.2 christos {
305 1.1 christos zipok=0;
306 1.1.1.2 christos }
307 1.1 christos else
308 1.1 christos {
309 1.1 christos int i,len;
310 1.1 christos int dot_found=0;
311 1.1 christos
312 1.1 christos zipok = 1 ;
313 1.1 christos strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
314 1.1.1.4 christos /* strncpy doesn't append the trailing NULL, of the string is too long. */
315 1.1 christos filename_try[ MAXFILENAME ] = '\0';
316 1.1 christos
317 1.1 christos len=(int)strlen(filename_try);
318 1.1 christos for (i=0;i<len;i++)
319 1.1 christos if (filename_try[i]=='.')
320 1.1 christos dot_found=1;
321 1.1 christos
322 1.1 christos if (dot_found==0)
323 1.1 christos strcat(filename_try,".zip");
324 1.1 christos
325 1.1 christos if (opt_overwrite==2)
326 1.1 christos {
327 1.1 christos /* if the file don't exist, we not append file */
328 1.1 christos if (check_exist_file(filename_try)==0)
329 1.1 christos opt_overwrite=1;
330 1.1 christos }
331 1.1 christos else
332 1.1 christos if (opt_overwrite==0)
333 1.1 christos if (check_exist_file(filename_try)!=0)
334 1.1 christos {
335 1.1 christos char rep=0;
336 1.1 christos do
337 1.1 christos {
338 1.1 christos char answer[128];
339 1.1 christos int ret;
340 1.1 christos printf("The file %s exists. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
341 1.1 christos ret = scanf("%1s",answer);
342 1.1 christos if (ret != 1)
343 1.1 christos {
344 1.1 christos exit(EXIT_FAILURE);
345 1.1 christos }
346 1.1 christos rep = answer[0] ;
347 1.1 christos if ((rep>='a') && (rep<='z'))
348 1.1 christos rep -= 0x20;
349 1.1 christos }
350 1.1 christos while ((rep!='Y') && (rep!='N') && (rep!='A'));
351 1.1 christos if (rep=='N')
352 1.1 christos zipok = 0;
353 1.1 christos if (rep=='A')
354 1.1 christos opt_overwrite = 2;
355 1.1 christos }
356 1.1 christos }
357 1.1 christos
358 1.1 christos if (zipok==1)
359 1.1 christos {
360 1.1 christos zipFile zf;
361 1.1 christos int errclose;
362 1.1 christos # ifdef USEWIN32IOAPI
363 1.1.1.2 christos zlib_filefunc64_def ffunc;
364 1.1.1.2 christos fill_win32_filefunc64A(&ffunc);
365 1.1.1.2 christos zf = zipOpen2_64(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc);
366 1.1 christos # else
367 1.1.1.2 christos zf = zipOpen64(filename_try,(opt_overwrite==2) ? 2 : 0);
368 1.1 christos # endif
369 1.1 christos
370 1.1 christos if (zf == NULL)
371 1.1 christos {
372 1.1 christos printf("error opening %s\n",filename_try);
373 1.1 christos err= ZIP_ERRNO;
374 1.1 christos }
375 1.1 christos else
376 1.1 christos printf("creating %s\n",filename_try);
377 1.1 christos
378 1.1 christos for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
379 1.1 christos {
380 1.1 christos if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) &&
381 1.1 christos ((argv[i][1]=='o') || (argv[i][1]=='O') ||
382 1.1 christos (argv[i][1]=='a') || (argv[i][1]=='A') ||
383 1.1 christos (argv[i][1]=='p') || (argv[i][1]=='P') ||
384 1.1.1.4 christos ((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
385 1.1 christos (strlen(argv[i]) == 2)))
386 1.1 christos {
387 1.1.1.4 christos FILE * fin = NULL;
388 1.1.1.3 christos size_t size_read;
389 1.1 christos const char* filenameinzip = argv[i];
390 1.1.1.2 christos const char *savefilenameinzip;
391 1.1 christos zip_fileinfo zi;
392 1.1 christos unsigned long crcFile=0;
393 1.1.1.2 christos int zip64 = 0;
394 1.1 christos
395 1.1 christos zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
396 1.1 christos zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
397 1.1 christos zi.dosDate = 0;
398 1.1 christos zi.internal_fa = 0;
399 1.1 christos zi.external_fa = 0;
400 1.1 christos filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
401 1.1 christos
402 1.1 christos /*
403 1.1 christos err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
404 1.1 christos NULL,0,NULL,0,NULL / * comment * /,
405 1.1 christos (opt_compress_level != 0) ? Z_DEFLATED : 0,
406 1.1 christos opt_compress_level);
407 1.1 christos */
408 1.1 christos if ((password != NULL) && (err==ZIP_OK))
409 1.1 christos err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
410 1.1 christos
411 1.1.1.2 christos zip64 = isLargeFile(filenameinzip);
412 1.1.1.2 christos
413 1.1.1.2 christos /* The path name saved, should not include a leading slash. */
414 1.1.1.2 christos /*if it did, windows/xp and dynazip couldn't read the zip file. */
415 1.1.1.2 christos savefilenameinzip = filenameinzip;
416 1.1.1.2 christos while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' )
417 1.1.1.2 christos {
418 1.1.1.2 christos savefilenameinzip++;
419 1.1.1.2 christos }
420 1.1.1.2 christos
421 1.1.1.2 christos /*should the zip file contain any path at all?*/
422 1.1.1.2 christos if( opt_exclude_path )
423 1.1.1.2 christos {
424 1.1.1.2 christos const char *tmpptr;
425 1.1.1.2 christos const char *lastslash = 0;
426 1.1.1.2 christos for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++)
427 1.1.1.2 christos {
428 1.1.1.2 christos if( *tmpptr == '\\' || *tmpptr == '/')
429 1.1.1.2 christos {
430 1.1.1.2 christos lastslash = tmpptr;
431 1.1.1.2 christos }
432 1.1.1.2 christos }
433 1.1.1.2 christos if( lastslash != NULL )
434 1.1.1.2 christos {
435 1.1.1.2 christos savefilenameinzip = lastslash+1; // base filename follows last slash.
436 1.1.1.2 christos }
437 1.1.1.2 christos }
438 1.1.1.2 christos
439 1.1.1.2 christos /**/
440 1.1.1.2 christos err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi,
441 1.1 christos NULL,0,NULL,0,NULL /* comment*/,
442 1.1 christos (opt_compress_level != 0) ? Z_DEFLATED : 0,
443 1.1 christos opt_compress_level,0,
444 1.1 christos /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
445 1.1 christos -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
446 1.1.1.2 christos password,crcFile, zip64);
447 1.1 christos
448 1.1 christos if (err != ZIP_OK)
449 1.1 christos printf("error in opening %s in zipfile\n",filenameinzip);
450 1.1 christos else
451 1.1 christos {
452 1.1.1.2 christos fin = FOPEN_FUNC(filenameinzip,"rb");
453 1.1 christos if (fin==NULL)
454 1.1 christos {
455 1.1 christos err=ZIP_ERRNO;
456 1.1 christos printf("error in opening %s for reading\n",filenameinzip);
457 1.1 christos }
458 1.1 christos }
459 1.1 christos
460 1.1 christos if (err == ZIP_OK)
461 1.1 christos do
462 1.1 christos {
463 1.1 christos err = ZIP_OK;
464 1.1.1.3 christos size_read = fread(buf,1,size_buf,fin);
465 1.1 christos if (size_read < size_buf)
466 1.1 christos if (feof(fin)==0)
467 1.1 christos {
468 1.1 christos printf("error in reading %s\n",filenameinzip);
469 1.1 christos err = ZIP_ERRNO;
470 1.1 christos }
471 1.1 christos
472 1.1 christos if (size_read>0)
473 1.1 christos {
474 1.1.1.3 christos err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
475 1.1 christos if (err<0)
476 1.1 christos {
477 1.1 christos printf("error in writing %s in the zipfile\n",
478 1.1 christos filenameinzip);
479 1.1 christos }
480 1.1 christos
481 1.1 christos }
482 1.1 christos } while ((err == ZIP_OK) && (size_read>0));
483 1.1 christos
484 1.1 christos if (fin)
485 1.1 christos fclose(fin);
486 1.1 christos
487 1.1 christos if (err<0)
488 1.1 christos err=ZIP_ERRNO;
489 1.1 christos else
490 1.1 christos {
491 1.1 christos err = zipCloseFileInZip(zf);
492 1.1 christos if (err!=ZIP_OK)
493 1.1 christos printf("error in closing %s in the zipfile\n",
494 1.1 christos filenameinzip);
495 1.1 christos }
496 1.1 christos }
497 1.1 christos }
498 1.1 christos errclose = zipClose(zf,NULL);
499 1.1 christos if (errclose != ZIP_OK)
500 1.1 christos printf("error in closing %s\n",filename_try);
501 1.1 christos }
502 1.1 christos else
503 1.1 christos {
504 1.1 christos do_help();
505 1.1 christos }
506 1.1 christos
507 1.1 christos free(buf);
508 1.1 christos return 0;
509 1.1 christos }
510