15 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) 
   16         #ifndef __USE_FILE_OFFSET64 
   17                 #define __USE_FILE_OFFSET64 
   19         #ifndef __USE_LARGEFILE64 
   20                 #define __USE_LARGEFILE64 
   22         #ifndef _LARGEFILE64_SOURCE 
   23                 #define _LARGEFILE64_SOURCE 
   25         #ifndef _FILE_OFFSET_BIT 
   26                 #define _FILE_OFFSET_BIT 64 
   32 #define FOPEN_FUNC(filename, mode) fopen(filename, mode) 
   33 #define FTELLO_FUNC(stream) ftello(stream) 
   34 #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) 
   36 #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) 
   37 #define FTELLO_FUNC(stream) ftello64(stream) 
   38 #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) 
   61 #define CASESENSITIVITY (0) 
   62 #define WRITEBUFFERSIZE (8192) 
   63 #define MAXFILENAME (256) 
   91   FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
 
   93   hFile = CreateFileA(
filename,GENERIC_READ | GENERIC_WRITE,
 
   94                       0,NULL,OPEN_EXISTING,0,NULL);
 
   95   GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
 
   96   DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
 
   97   LocalFileTimeToFileTime(&ftLocal,&ftm);
 
   98   SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
 
  101 #if defined(unix) || defined(__APPLE__) 
  105   newdate.tm_sec = tmu_date.
tm_sec;
 
  106   newdate.tm_min=tmu_date.
tm_min;
 
  107   newdate.tm_hour=tmu_date.
tm_hour;
 
  108   newdate.tm_mday=tmu_date.
tm_mday;
 
  109   newdate.tm_mon=tmu_date.
tm_mon;
 
  111       newdate.tm_year=tmu_date.
tm_year - 1900;
 
  113       newdate.tm_year=tmu_date.
tm_year ;
 
  116   ut.actime=ut.modtime=mktime(&newdate);
 
  131     ret = _mkdir(dirname);
 
  133     ret = mkdir (dirname,0775);
 
  135     ret = mkdir (dirname,0775);
 
  145   size_t len = strlen(newdir);
 
  153                 printf(
"Error allocating memory\n");
 
  172       while(*
p && *
p != 
'\\' && *
p != 
'/')
 
  192     printf(
"MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
 
  193     printf(
"more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
 
  198     printf(
"Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
 
  199            "  -e  Extract without pathname (junk paths)\n" \
 
  200            "  -x  Extract with pathname\n" \
 
  203            "  -d  directory to extract into\n" \
 
  204            "  -o  overwrite files without prompting\n" \
 
  205            "  -p  extract crypted file using password\n\n");
 
  225       int size_display_string = 19-pos_string;
 
  226       while (size_char > size_display_string)
 
  245         printf(
"error %d with zipfile in unzGetGlobalInfo \n",
err);
 
  246     printf(
"  Length  Method     Size Ratio   Date    Time   CRC-32     Name\n");
 
  247     printf(
"  ------  ------     ---- -----   ----    ----   ------     ----\n");
 
  250         char filename_inzip[256];
 
  253         const char *string_method;
 
  258             printf(
"error %d with zipfile in unzGetCurrentFileInfo\n",
err);
 
  265         if ((file_info.
flag & 1) != 0)
 
  269             string_method=
"Stored";
 
  275               string_method=
"Defl:N";
 
  277               string_method=
"Defl:X";
 
  278             else if ((iLevel==2) || (iLevel==3))
 
  279               string_method=
"Defl:F"; 
 
  284               string_method=
"BZip2 ";
 
  287             string_method=
"Unkn. ";
 
  290         printf(
"  %6s%c",string_method,charCrypt);
 
  292         printf(
" %3lu%%  %2.2lu-%2.2lu-%2.2lu  %2.2lu:%2.2lu  %8.8lx   %s\n",
 
  298                 (
uLong)file_info.
crc,filename_inzip);
 
  304                 printf(
"error %d with zipfile in unzGoToNextFile\n",
err);
 
  316     const int* popt_extract_without_path;
 
  318     const char* password;
 
  320     char filename_inzip[256];
 
  321     char* filename_withoutpath;
 
  333         printf(
"error %d with zipfile in unzGetCurrentFileInfo\n",
err);
 
  338     buf = (
void*)malloc(size_buf);
 
  341         printf(
"Error allocating memory\n");
 
  345     p = filename_withoutpath = filename_inzip;
 
  348         if (((*
p)==
'/') || ((*
p)==
'\\'))
 
  349             filename_withoutpath = 
p+1;
 
  353     if ((*filename_withoutpath)==
'\0')
 
  355         if ((*popt_extract_without_path)==0)
 
  357             printf(
"creating directory: %s\n",filename_inzip);
 
  363         const char* write_filename;
 
  366         if ((*popt_extract_without_path)==0)
 
  367             write_filename = filename_inzip;
 
  369             write_filename = filename_withoutpath;
 
  374             printf(
"error %d with zipfile in unzOpenCurrentFilePassword\n",
err);
 
  377         if (((*popt_overwrite)==0) && (
err==
UNZ_OK))
 
  382             if (ftestexist!=NULL)
 
  390                     printf(
"The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
 
  391                     ret = scanf(
"%1s",answer);
 
  397                     if ((
rep>=
'a') && (
rep<=
'z'))
 
  400                 while ((
rep!=
'Y') && (
rep!=
'N') && (
rep!=
'A'));
 
  414             if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
 
  415                                 (filename_withoutpath!=(
char*)filename_inzip))
 
  417                 char c=*(filename_withoutpath-1);
 
  418                 *(filename_withoutpath-1)=
'\0';
 
  420                 *(filename_withoutpath-1)=
c;
 
  426                 printf(
"error opening %s\n",write_filename);
 
  432             printf(
" extracting: %s\n",write_filename);
 
  439                     printf(
"error %d with zipfile in unzReadCurrentFile\n",
err);
 
  443                     if (fwrite(
buf,(
unsigned)
err,1,fout)!=1)
 
  445                         printf(
"error in writing extracted file\n");
 
  464                 printf(
"error %d with zipfile in unzCloseCurrentFile\n",
err);
 
  476 static int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
 
  478     int opt_extract_without_path;
 
  480     const char* password;
 
  488         printf(
"error %d with zipfile in unzGetGlobalInfo \n",
err);
 
  502                 printf(
"error %d with zipfile in unzGoToNextFile\n",
err);
 
  514     int opt_extract_without_path;
 
  516     const char* password;
 
  537     const char *zipfilename=NULL;
 
  538     const char *filename_to_extract=NULL;
 
  539     const char *password=NULL;
 
  544     int opt_do_extract=1;
 
  545     int opt_do_extract_withoutpath=0;
 
  547     int opt_extractdir=0;
 
  548     const char *dirname=NULL;
 
  563                 const char *
p=argv[
i]+1;
 
  568                     if ((
c==
'l') || (
c==
'L'))
 
  570                     if ((
c==
'v') || (
c==
'V'))
 
  572                     if ((
c==
'x') || (
c==
'X'))
 
  574                     if ((
c==
'e') || (
c==
'E'))
 
  575                         opt_do_extract = opt_do_extract_withoutpath = 1;
 
  576                     if ((
c==
'o') || (
c==
'O'))
 
  578                     if ((
c==
'd') || (
c==
'D'))
 
  584                     if (((
c==
'p') || (
c==
'P')) && (
i+1<argc))
 
  593                 if (zipfilename == NULL)
 
  594                     zipfilename = argv[
i];
 
  595                 else if ((filename_to_extract==NULL) && (!opt_extractdir))
 
  596                         filename_to_extract = argv[
i] ;
 
  601     if (zipfilename!=NULL)
 
  604 #        ifdef USEWIN32IOAPI 
  612 #        ifdef USEWIN32IOAPI 
  620             strcat(filename_try,
".zip");
 
  621 #            ifdef USEWIN32IOAPI 
  631         printf(
"Cannot open %s or %s.zip\n",zipfilename,zipfilename);
 
  634     printf(
"%s opened\n",filename_try);
 
  638     else if (opt_do_extract==1)
 
  641         if (opt_extractdir && _chdir(dirname))
 
  643         if (opt_extractdir && chdir(dirname))
 
  646           printf(
"Error changing into %s, aborting\n", dirname);
 
  650         if (filename_to_extract == NULL)
 
  651             ret_value = 
do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password);
 
  653             ret_value = 
do_extract_onefile(uf, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password);