zip.h
上传用户:jnfxsk
上传日期:2022-06-16
资源大小:3675k
文件大小:7k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. /* zip.h -- IO for compress .zip files using zlib
  2. Version 1.01, May 8th, 2004
  3. Copyright (C) 1998-2004 Gilles Vollant
  4. This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
  5. WinZip, InfoZip tools and compatible.
  6. Encryption and multi volume ZipFile (span) are not supported.
  7. Old compressions used by old PKZip 1.x are not supported
  8. For uncompress .zip file, look at unzip.h
  9. I WAIT FEEDBACK at mail info@winimage.com
  10. Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
  11. Condition of use and distribution are the same than zlib :
  12. This software is provided 'as-is', without any express or implied
  13. warranty.  In no event will the authors be held liable for any damages
  14. arising from the use of this software.
  15. Permission is granted to anyone to use this software for any purpose,
  16. including commercial applications, and to alter it and redistribute it
  17. freely, subject to the following restrictions:
  18. 1. The origin of this software must not be misrepresented; you must not
  19. claim that you wrote the original software. If you use this software
  20. in a product, an acknowledgment in the product documentation would be
  21. appreciated but is not required.
  22. 2. Altered source versions must be plainly marked as such, and must not be
  23. misrepresented as being the original software.
  24. 3. This notice may not be removed or altered from any source distribution.
  25.  */
  26. /* for more info about .ZIP format, see
  27. http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
  28. http://www.info-zip.org/pub/infozip/doc/
  29. PkWare has also a specification at :
  30. ftp://ftp.pkware.com/probdesc.zip
  31.  */
  32. #ifndef _zip_H
  33.   #define _zip_H
  34.   #ifdef __cplusplus
  35.     extern "C"
  36.     {
  37.     #endif
  38.     #ifndef _ZLIB_H
  39.       #include "zlib.h"
  40.     #endif
  41.     #ifndef _ZLIBIOAPI_H
  42.       #include "ioapi.h"
  43.     #endif
  44.     #if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
  45.       /* like the STRICT of WIN32, we define a pointer that cannot be converted
  46.       from (void*) without cast */
  47.       typedef struct TagzipFile__
  48.       {
  49.         int unused;
  50.       } zipFile__;
  51.       typedef zipFile__ *zipFile;
  52.     #else
  53.       typedef voidp zipFile;
  54.     #endif
  55.     #define ZIP_OK                          (0)
  56.     #define ZIP_EOF                         (0)
  57.     #define ZIP_ERRNO                       (Z_ERRNO)
  58.     #define ZIP_PARAMERROR                  (-102)
  59.     #define ZIP_BADZIPFILE                  (-103)
  60.     #define ZIP_INTERNALERROR               (-104)
  61.     #ifndef DEF_MEM_LEVEL
  62.       #if MAX_MEM_LEVEL >= 8
  63.         #define DEF_MEM_LEVEL 8
  64.       #else
  65.         #define DEF_MEM_LEVEL  MAX_MEM_LEVEL
  66.       #endif
  67.     #endif
  68.     /* default memLevel */
  69.     /* tm_zip contain date/time info */
  70.     typedef struct tm_zip_s
  71.     {
  72.       uInt tm_sec; /* seconds after the minute - [0,59] */
  73.       uInt tm_min; /* minutes after the hour - [0,59] */
  74.       uInt tm_hour; /* hours since midnight - [0,23] */
  75.       uInt tm_mday; /* day of the month - [1,31] */
  76.       uInt tm_mon; /* months since January - [0,11] */
  77.       uInt tm_year; /* years - [1980..2044] */
  78.     } tm_zip;
  79.     typedef struct
  80.     {
  81.       tm_zip tmz_date; /* date in understandable format           */
  82.       uLong dosDate; /* if dos_date == 0, tmu_date is used      */
  83.        /*    uLong       flag;        */ /* general purpose bit flag        2 bytes */
  84.       uLong internal_fa; /* internal file attributes        2 bytes */
  85.       uLong external_fa; /* external file attributes        4 bytes */
  86.     } zip_fileinfo;
  87.     typedef const char *zipcharpc;
  88.     #define APPEND_STATUS_CREATE        (0)
  89.     #define APPEND_STATUS_CREATEAFTER   (1)
  90.     #define APPEND_STATUS_ADDINZIP      (2)
  91.     extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
  92.     /*
  93.     Create a zipfile.
  94.     pathname contain on Windows XP a filename like "c:\zlib\zlib113.zip" or on
  95.     an Unix computer "zlib/zlib113.zip".
  96.     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
  97.     will be created at the end of the file.
  98.     (useful if the file contain a self extractor code)
  99.     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
  100.     add files in existing zip (be sure you don't add file that doesn't exist)
  101.     If the zipfile cannot be opened, the return value is NULL.
  102.     Else, the return value is a zipFile Handle, usable with other function
  103.     of this zip package.
  104.      */
  105.     /* Note : there is no delete function into a zipfile.
  106.     If you want delete file into a zipfile, you must open a zipfile, and create another
  107.     Of couse, you can use RAW reading and writing to copy the file you did not want delte
  108.      */
  109.     extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc_def));
  110.     extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level));
  111.     /*
  112.     Open a file in the ZIP for writing.
  113.     filename : the filename in zip (if NULL, '-' without quote will be used
  114.      *zipfi contain supplemental information
  115.     if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
  116.     contains the extrafield data the the local header
  117.     if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
  118.     contains the extrafield data the the local header
  119.     if comment != NULL, comment contain the comment string
  120.     method contain the compression method (0 for store, Z_DEFLATED for deflate)
  121.     level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
  122.      */
  123.     extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw));
  124.     /*
  125.     Same than zipOpenNewFileInZip, except if raw=1, we write raw file
  126.      */
  127.     extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCtypting));
  128.     /*
  129.     Same than zipOpenNewFileInZip2, except
  130.     windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
  131.     password : crypting password (NULL for no crypting)
  132.     crcForCtypting : crc of file to compress (needed for crypting)
  133.      */
  134.     extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, const void *buf, unsigned len));
  135.     /*
  136.     Write data in the zipfile
  137.      */
  138.     extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
  139.     /*
  140.     Close the current file in the zipfile
  141.      */
  142.     extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, uLong uncompressed_size, uLong crc32));
  143.     /*
  144.     Close the current file in the zipfile, for fiel opened with
  145.     parameter raw=1 in zipOpenNewFileInZip2
  146.     uncompressed_size and crc32 are value for the uncompressed size
  147.      */
  148.     extern int ZEXPORT zipClose OF((zipFile file, const char *global_comment));
  149.     /*
  150.     Close the zipfile
  151.      */
  152.     #ifdef __cplusplus
  153.     }
  154.   #endif
  155. #endif /* _zip_H */