![]() |
![]() |
00001 /****************************************************************************** 00002 * GX ZLIB header file - V7.2.12 00003 * 00004 * 2005-2015 (c) Adaptive Recognition (https://adaptiverecognition.com) 00005 ******************************************************************************/ 00015 /******************************************************************************/ 00016 #ifndef GXZLIB_INCL 00017 #define GXZLIB_INCL 00018 /******************************************************************************/ 00019 #include "gxsd.h" 00020 #if defined(WIN32) && !defined(GX_DOTNET) 00021 #include <windows.h> 00022 #endif 00023 #include <assert.h> 00024 /******************************************************************************/ 00025 #ifdef GX_NAMESPACES 00026 namespace gx { 00027 #endif 00028 00029 #ifdef GX_DOTNET 00030 #pragma unmanaged 00031 #endif 00032 00033 /******************************************************************************/ 00034 #if !defined(GX_SWIGIF) && !defined(GX_MANUAL) /*(*/ 00035 /******************************************************************************/ 00037 enum { 00038 GX_CALL_GZCOMPRESS = GX_CALL_GROUP_GX_ZLIB, 00039 GX_CALL_GZUNCOMPRESS, 00041 GX_CALL_CREATEGZ, 00042 GX_CALL_OPENGZ, 00043 GX_CALL_CLOSEGZ, 00044 GX_CALL_READGZ, 00045 GX_CALL_WRITEGZ, 00047 GX_CALL_CREATEZIP, 00048 GX_CALL_OPENZIP, 00049 GX_CALL_CLOSEZIP, 00050 GX_CALL_GETZIPINFO, 00051 GX_CALL_GETZIPCOMMENT, 00053 GX_CALL_FIRSTFILEINZIP, 00054 GX_CALL_NEXTFILEINZIP, 00055 GX_CALL_LOCATEFILEINZIP, 00056 GX_CALL_FILEINFOINZIP, 00058 GX_CALL_OPENFILEINZIP, 00059 GX_CALL_READFROMFILEINZIP, 00060 GX_CALL_READLEXFIELDZIP, 00062 GX_CALL_CREATEFILEINZIP, 00063 GX_CALL_WRITETOFILEINZIP, 00064 GX_CALL_CLOSEFILEINZIP, 00065 GX_CALL_GETINITIALZIPCRC, 00066 GX_CALL_CALCULATEZIPCRC, 00068 // Unicode extensions 00069 GX_CALL_CREATEGZW = GX_CALL_GROUP_GX_ZLIB + 0x100, 00070 GX_CALL_OPENGZW, 00071 GX_CALL_CREATEZIPW, 00072 GX_CALL_OPENZIPW, 00073 GX_CALL_CLOSEZIPW, 00074 GX_CALL_GETZIPCOMMENTW, 00076 GX_CALL_FIRSTFILEINZIPW, 00077 GX_CALL_NEXTFILEINZIPW, 00078 GX_CALL_LOCATEFILEINZIPW, 00079 GX_CALL_FILEINFOINZIPW, 00081 GX_CALL_OPENFILEINZIPW, 00082 GX_CALL_CREATEFILEINZIPW, 00084 GX_CALL_CREATEZIPINMEMORY, 00085 GX_CALL_GETZIPINMEMORY, 00086 GX_CALL_OPENZIPINMEMORY, 00087 }; 00088 #endif /* GX_SWIGIF GX_MANUAL )*/ 00089 00090 #ifdef GX_DOTNET 00091 #pragma managed 00092 #endif 00093 00095 GX_ENUM GX_ZLEVELS { 00096 GX_Z_NO_COMPRESSION = 0, 00097 GX_Z_BEST_SPEED = 1, 00098 GX_Z_BEST_COMPRESSION = 9, 00099 GX_Z_DEFAULT_COMPRESSION = -1 00100 }; 00101 00103 GX_ENUM GX_ZSTRATEGIES { 00104 GX_Z_FILTERED = 1, 00105 GX_Z_HUFFMAN_ONLY = 2, 00106 GX_Z_RLE = 3, 00107 GX_Z_FIXED = 4, 00108 GX_Z_DEFAULT_STRATEGY = 0 00109 }; 00110 00112 GX_ENUM GX_ZMETHODS { 00113 GX_Z_DEFLATED = 8 00114 }; 00115 00117 GX_ENUM GX_CREATEZIPMODES { 00118 GX_ZIP_CREATE = 0, 00119 GX_ZIP_CREATEAFTER, 00120 GX_ZIP_ADDINZIP 00121 }; 00122 /******************************************************************************/ 00123 #ifdef GX_DOTNET 00124 #pragma unmanaged 00125 #endif 00126 /******************************************************************************/ 00127 #if !defined(GX_SWIGIF) && !defined(GX_MANUAL) /*(*/ 00128 00129 struct GX_PARM_GZCOMPRESS { 00130 void *target; 00131 int tgtlen; 00132 const void *source; 00133 int srclen; 00134 int level; 00135 }; 00136 00138 struct GX_PARM_GZUNCOMPRESS { 00139 void *target; 00140 int tgtlen; 00141 const void *source; 00142 int srclen; 00143 }; 00144 00146 struct GX_PARM_CREATEGZ { 00147 const char *filename; 00148 int level; 00149 int strategy; 00150 }; 00151 00153 struct GX_PARM_CREATEGZW { 00154 const wchar_t *filename; 00155 int level; 00156 int strategy; 00157 }; 00158 00160 struct GX_PARM_OPENGZ { 00161 const char *filename; 00162 }; 00163 00165 struct GX_PARM_OPENGZW { 00166 const wchar_t *filename; 00167 }; 00168 00170 struct GX_PARM_READGZ { 00171 void *buffer; 00172 int buflen; 00173 }; 00174 00176 struct GX_PARM_WRITEGZ { 00177 const void *buffer; 00178 int buflen; 00179 }; 00180 00182 struct GX_PARM_CREATEZIP { 00183 const char *filename; 00184 int mode; 00185 }; 00186 00188 struct GX_PARM_CREATEZIPW { 00189 const wchar_t *filename; 00190 int mode; 00191 }; 00192 00194 struct GX_PARM_OPENZIP { 00195 const char *filename; 00196 }; 00197 00199 struct GX_PARM_OPENZIPW { 00200 const wchar_t *filename; 00201 }; 00202 00204 struct GX_PARM_CREATEZIPINMEMORY { 00205 int mode; 00206 }; 00207 00209 struct GX_PARM_GETZIPINMEMORY { 00210 void **pbuffer; 00211 int* pbuflen; 00212 }; 00213 00215 struct GX_PARM_OPENZIPINMEMORY { 00216 void *buffer; 00217 int buflen; 00218 }; 00219 00221 struct GX_PARM_CLOSEZIP { 00222 const char *comment; 00223 }; 00224 00226 struct GX_PARM_CLOSEZIPW { 00227 const wchar_t *comment; 00228 }; 00229 00231 struct GX_PARM_GETZIPINFO { 00232 int nentries; 00233 int commentlen; 00234 }; 00235 00237 struct GX_PARM_GETZIPCOMMENT { 00238 char *target; 00239 int tlen; 00240 }; 00241 00243 struct GX_PARM_GETZIPCOMMENTW { 00244 wchar_t *target; 00245 int tlen; 00246 }; 00247 00249 struct GX_ZIPFILEINFO { 00250 int tm_sec; 00251 int tm_min; 00252 int tm_hour; 00253 int tm_mday; 00254 int tm_mon; 00255 int tm_year; 00257 int dosdate; 00258 int internal_fa; 00259 int external_fa; 00260 }; 00261 00262 #ifndef __cplusplus 00263 00264 typedef struct GX_ZIPFILEINFO GX_ZIPFILEINFO; 00265 #endif 00266 00268 struct GX_PARM_CREATEFILEINZIP { 00269 const char *filename; 00270 const GX_ZIPFILEINFO *info; 00271 const char *comment; 00272 int level; 00273 int strategy; 00274 const char *password; 00275 unsigned int crc; 00276 const void *exflocal; 00277 int exflocal_len; 00278 const void *exfglobal; 00279 int exfglobal_len; 00280 }; 00281 00283 struct GX_PARM_CREATEFILEINZIPW { 00284 const wchar_t *filename; 00285 const GX_ZIPFILEINFO *info; 00286 const wchar_t *comment; 00287 int level; 00288 int strategy; 00289 const wchar_t *password; 00290 unsigned int crc; 00291 const void *exflocal; 00292 int exflocal_len; 00293 const void *exfglobal; 00294 int exfglobal_len; 00295 }; 00296 00298 struct GX_PARM_WRITETOFILEINZIP { 00299 const void *buffer; 00300 int buflen; 00301 }; 00302 00304 struct GX_ZIPFILEDETINFO { 00305 // in 00306 char *filename; 00307 int filename_len; 00308 void *gextrafield; 00309 int gextrafield_len; 00310 char *comment; 00311 int comment_len; 00312 // out 00313 int version; 00314 int version_needed; 00315 int flag; 00316 int method; 00317 int dosdate; 00318 unsigned int crc; 00319 int compressed_size; 00320 int uncompressed_size; 00321 int size_filename; 00322 int size_file_extra; 00323 int size_file_comment; 00324 int disk_num_start; 00325 int internal_fa; 00326 int external_fa; 00327 int tm_sec; 00328 int tm_min; 00329 int tm_hour; 00330 int tm_mday; 00331 int tm_mon; 00332 int tm_year; 00333 }; 00334 00335 #ifndef __cplusplus 00336 00337 typedef struct GX_ZIPFILEDETINFO GX_ZIPFILEDETINFO; 00338 #endif 00339 00341 struct GX_ZIPFILEDETINFOW { 00342 // in 00343 wchar_t *filename; 00344 int filename_len; 00345 void *gextrafield; 00346 int gextrafield_len; 00347 wchar_t *comment; 00348 int comment_len; 00349 // out 00350 int version; 00351 int version_needed; 00352 int flag; 00353 int method; 00354 int dosdate; 00355 unsigned int crc; 00356 int compressed_size; 00357 int uncompressed_size; 00358 int size_filename; 00359 int size_file_extra; 00360 int size_file_comment; 00361 int disk_num_start; 00362 int internal_fa; 00363 int external_fa; 00364 int tm_sec; 00365 int tm_min; 00366 int tm_hour; 00367 int tm_mday; 00368 int tm_mon; 00369 int tm_year; 00370 }; 00371 00372 #ifndef __cplusplus 00373 00374 typedef struct GX_ZIPFILEDETINFOW GX_ZIPFILEDETINFOW; 00375 #endif 00376 00378 struct GX_PARM_LOCATEFILEINZIP { 00379 GX_ZIPFILEDETINFO *finfo; 00380 const char *filename; 00381 int casesensitivity; 00382 }; 00383 00385 struct GX_PARM_LOCATEFILEINZIPW { 00386 GX_ZIPFILEDETINFOW *finfo; 00387 const wchar_t *filename; 00388 int casesensitivity; 00389 }; 00390 00392 struct GX_PARM_OPENFILEINZIP { 00393 int method; 00394 int level; 00395 const char *password; 00396 }; 00397 00399 struct GX_PARM_OPENFILEINZIPW { 00400 int method; 00401 int level; 00402 const wchar_t *password; 00403 }; 00404 00406 struct GX_PARM_READFROMFILEINZIP { 00407 void *buffer; 00408 int buflen; 00409 }; 00410 00412 struct GX_PARM_CALCULATEZIPCRC { 00413 unsigned int crc; 00414 const void *buffer; 00415 int buflen; 00416 }; 00417 00419 struct GX_PARM_GETINITIALZIPCRC { 00420 unsigned int crc; 00421 }; 00422 00424 struct GX_PARM_READLEXFIELDZIP { 00425 void *buffer; 00426 int buflen; 00427 }; 00428 00429 #endif /* GX_SWIGIF GX_MANUAL )*/ 00430 00431 /******************************************************************************/ 00432 #if !defined(NO_GX_FUNCTIONS) && !defined(GX_SWIGIF) 00433 /******************************************************************************/ 00434 00435 /******************************************************************************/ 00439 /******************************************************************************/ 00440 00441 /******************************************************************************/ 00454 inline int gx_gzcompress(gxHANDLE handle, void *target, int *tgtlen, 00455 const void *source, int srclen, int level) { 00456 00457 struct GX_PARM_GZCOMPRESS gzc; 00458 int st; 00459 00460 assert(target && tgtlen && (*tgtlen > 0) && source && (srclen > 0)); 00461 00462 gzc.target = target; 00463 gzc.tgtlen = *tgtlen; 00464 gzc.source = source; 00465 gzc.srclen = srclen; 00466 gzc.level = level; 00467 st = gx_call(handle, GX_CALL_GZCOMPRESS, &gzc); 00468 if(st) *tgtlen = gzc.tgtlen; 00469 return st; 00470 } 00471 /******************************************************************************/ 00483 inline int gx_gzcompressd(void *target, int *tgtlen, 00484 const void *source, int srclen, int level) { 00485 00486 return gx_gzcompress(gx_direct(GX_CALL_GROUP_GX_ZLIB), 00487 target, tgtlen, source, srclen, level); 00488 } 00489 00490 #ifdef __cplusplus 00491 /******************************************************************************/ 00503 inline int gx_gzcompress(void *target, int *tgtlen, 00504 const void *source, int srclen, int level) { 00505 00506 return gx_gzcompressd(target, tgtlen, source, srclen, level); 00507 } 00508 #endif 00509 00510 /******************************************************************************/ 00522 inline int gx_gzuncompress(gxHANDLE handle, void *target, int *tgtlen, 00523 const void *source, int srclen) { 00524 00525 struct GX_PARM_GZUNCOMPRESS gzu; 00526 int st; 00527 00528 assert(target && tgtlen && (*tgtlen > 0) && source && (srclen > 0)); 00529 00530 gzu.target = target; 00531 gzu.tgtlen = *tgtlen; 00532 gzu.source = source; 00533 gzu.srclen = srclen; 00534 st = gx_call(handle, GX_CALL_GZUNCOMPRESS, &gzu); 00535 if(st) *tgtlen = gzu.tgtlen; 00536 return st; 00537 } 00538 /******************************************************************************/ 00549 inline int gx_gzuncompressd(void *target, int *tgtlen, 00550 const void *source, int srclen) { 00551 00552 return gx_gzuncompress(gx_direct(GX_CALL_GROUP_GX_ZLIB), 00553 target, tgtlen, source, srclen); 00554 } 00555 00556 #ifdef __cplusplus 00557 /******************************************************************************/ 00568 inline int gx_gzuncompress(void *target, int *tgtlen, 00569 const void *source, int srclen) { 00570 return gx_gzuncompressd(target, tgtlen, source, srclen); 00571 } 00572 #endif 00573 00574 /******************************************************************************/ 00585 inline int gx_creategz(gxHANDLE handle, const wchar_t *filename, int level, int strategy) { 00586 struct GX_PARM_CREATEGZW cgz; 00587 assert(filename); 00588 cgz.filename = filename; 00589 cgz.level = level; 00590 cgz.strategy = strategy; 00591 return gx_call(handle, GX_CALL_CREATEGZW, &cgz); 00592 } 00593 00594 /******************************************************************************/ 00605 inline int gx_creategza(gxHANDLE handle, const char *filename, int level, int strategy) { 00606 struct GX_PARM_CREATEGZ cgz; 00607 assert(filename); 00608 cgz.filename = filename; 00609 cgz.level = level; 00610 cgz.strategy = strategy; 00611 return gx_call(handle, GX_CALL_CREATEGZ, &cgz); 00612 } 00613 00614 #ifdef __cplusplus 00615 /******************************************************************************/ 00626 inline int gx_creategz(gxHANDLE handle, const char *filename, int level, int strategy) { 00627 return gx_creategza(handle, filename, level, strategy); 00628 } 00629 #endif 00630 00631 /******************************************************************************/ 00638 inline int gx_opengz(gxHANDLE handle, const wchar_t *filename) { 00639 struct GX_PARM_OPENGZW ogz; 00640 assert(filename); 00641 ogz.filename = filename; 00642 return gx_call(handle, GX_CALL_OPENGZW, &ogz); 00643 } 00644 00645 /******************************************************************************/ 00652 inline int gx_opengza(gxHANDLE handle, const char *filename) { 00653 struct GX_PARM_OPENGZ ogz; 00654 assert(filename); 00655 ogz.filename = filename; 00656 return gx_call(handle, GX_CALL_OPENGZ, &ogz); 00657 } 00658 00659 #ifdef __cplusplus 00660 /******************************************************************************/ 00667 inline int gx_opengz(gxHANDLE handle, const char *filename) { 00668 return gx_opengza(handle, filename); 00669 } 00670 #endif 00671 00672 /******************************************************************************/ 00678 inline int gx_closegz(gxHANDLE handle) { 00679 return gx_call(handle, GX_CALL_CLOSEGZ, (void *)0); 00680 } 00681 00682 /******************************************************************************/ 00691 inline int gx_readgz(gxHANDLE handle, void *buffer, int *buflen) { 00692 struct GX_PARM_READGZ rgz; 00693 int st; 00694 assert(buffer && buflen); 00695 rgz.buffer = buffer; 00696 rgz.buflen = *buflen; 00697 st = gx_call(handle, GX_CALL_READGZ, &rgz); 00698 if(st) *buflen = rgz.buflen; 00699 return st; 00700 } 00701 00702 /******************************************************************************/ 00710 inline int gx_writegz(gxHANDLE handle, const void *buffer, int buflen) { 00711 struct GX_PARM_WRITEGZ wgz; 00712 assert(buffer && buflen); 00713 wgz.buffer = buffer; 00714 wgz.buflen = buflen; 00715 return gx_call(handle, GX_CALL_WRITEGZ, &wgz); 00716 } 00717 00718 /******************************************************************************/ 00726 inline int gx_createzip(gxHANDLE handle, const wchar_t *filename, int mode) { 00727 struct GX_PARM_CREATEZIPW czip; 00728 assert(filename); 00729 czip.filename = filename; 00730 czip.mode = mode; 00731 return gx_call(handle, GX_CALL_CREATEZIPW, &czip); 00732 } 00733 00734 /******************************************************************************/ 00742 inline int gx_createzipa(gxHANDLE handle, const char *filename, int mode) { 00743 struct GX_PARM_CREATEZIP czip; 00744 assert(filename); 00745 czip.filename = filename; 00746 czip.mode = mode; 00747 return gx_call(handle, GX_CALL_CREATEZIP, &czip); 00748 } 00749 00750 #ifdef __cplusplus 00751 /******************************************************************************/ 00759 inline int gx_createzip(gxHANDLE handle, const char *filename, int mode) { 00760 return gx_createzipa(handle, filename, mode); 00761 } 00762 #endif 00763 00764 /******************************************************************************/ 00771 inline int gx_openzip(gxHANDLE handle, const wchar_t *filename) { 00772 struct GX_PARM_OPENZIPW ozip; 00773 assert(filename); 00774 ozip.filename = filename; 00775 return gx_call(handle, GX_CALL_OPENZIPW, &ozip); 00776 } 00777 00778 /******************************************************************************/ 00785 inline int gx_openzipa(gxHANDLE handle, const char *filename) { 00786 struct GX_PARM_OPENZIP ozip; 00787 assert(filename); 00788 ozip.filename = filename; 00789 return gx_call(handle, GX_CALL_OPENZIP, &ozip); 00790 } 00791 00792 #ifdef __cplusplus 00793 /******************************************************************************/ 00800 inline int gx_openzip(gxHANDLE handle, const char *filename) { 00801 return gx_openzipa(handle, filename); 00802 } 00803 #endif 00804 00805 /******************************************************************************/ 00812 inline int gx_createzipinmemory(gxHANDLE handle, int mode) { 00813 struct GX_PARM_CREATEZIPINMEMORY czip; 00814 czip.mode = mode; 00815 return gx_call(handle, GX_CALL_CREATEZIPINMEMORY, &czip); 00816 } 00817 00818 /******************************************************************************/ 00826 inline int gx_getzipinmemory(gxHANDLE handle, void** pbuffer, int* pbuflen) { 00827 struct GX_PARM_GETZIPINMEMORY zip; 00828 assert(pbuffer); 00829 assert(pbuflen); 00830 zip.pbuffer = pbuffer; 00831 zip.pbuflen = pbuflen; 00832 return gx_call(handle, GX_CALL_GETZIPINMEMORY, &zip); 00833 } 00834 00835 /******************************************************************************/ 00843 inline int gx_openzipinmemory(gxHANDLE handle, void* buffer, int buflen) { 00844 struct GX_PARM_OPENZIPINMEMORY ozip; 00845 assert(buffer); 00846 assert(buflen); 00847 ozip.buffer = buffer; 00848 ozip.buflen = buflen; 00849 return gx_call(handle, GX_CALL_OPENZIPINMEMORY, &ozip); 00850 } 00851 00852 00853 /******************************************************************************/ 00860 inline int gx_closezip(gxHANDLE handle, const wchar_t *comment) { 00861 struct GX_PARM_CLOSEZIPW czip; 00862 czip.comment = comment; 00863 return gx_call(handle, GX_CALL_CLOSEZIPW, &czip); 00864 } 00865 00866 /******************************************************************************/ 00873 inline int gx_closezipa(gxHANDLE handle, const char *comment) { 00874 struct GX_PARM_CLOSEZIP czip; 00875 czip.comment = comment; 00876 return gx_call(handle, GX_CALL_CLOSEZIP, &czip); 00877 } 00878 00879 #ifdef __cplusplus 00880 /******************************************************************************/ 00887 inline int gx_closezip(gxHANDLE handle, const char *comment = (const char *)0) { 00888 return gx_closezipa(handle, comment); 00889 } 00890 #endif 00891 00892 /******************************************************************************/ 00899 inline int gx_getzipinfo(gxHANDLE handle, struct GX_PARM_GETZIPINFO *info) { 00900 assert(info); 00901 return gx_call(handle, GX_CALL_GETZIPINFO, info); 00902 } 00903 00904 /******************************************************************************/ 00913 inline int gx_getzipcomment(gxHANDLE handle, wchar_t *target, int *tlen) { 00914 struct GX_PARM_GETZIPCOMMENTW gzc; 00915 int st; 00916 assert(target && tlen && (*tlen > 0)); 00917 gzc.target = target; 00918 gzc.tlen = *tlen; 00919 st = gx_call(handle, GX_CALL_GETZIPCOMMENTW, &gzc); 00920 if(st) *tlen = gzc.tlen; 00921 return st; 00922 } 00923 00924 /******************************************************************************/ 00933 inline int gx_getzipcommenta(gxHANDLE handle, char *target, int *tlen) { 00934 struct GX_PARM_GETZIPCOMMENT gzc; 00935 int st; 00936 assert(target && tlen && (*tlen > 0)); 00937 gzc.target = target; 00938 gzc.tlen = *tlen; 00939 st = gx_call(handle, GX_CALL_GETZIPCOMMENT, &gzc); 00940 if(st) *tlen = gzc.tlen; 00941 return st; 00942 } 00943 00944 #ifdef __cplusplus 00945 /******************************************************************************/ 00954 inline int gx_getzipcomment(gxHANDLE handle, char *target, int *tlen) { 00955 return gx_getzipcommenta(handle, target, tlen); 00956 } 00957 #endif 00958 00959 /******************************************************************************/ 00966 inline int gx_createfileinzip(gxHANDLE handle, struct GX_PARM_CREATEFILEINZIPW *cfz) { 00967 assert(cfz); 00968 return gx_call(handle, GX_CALL_CREATEFILEINZIPW, cfz); 00969 } 00970 00971 /******************************************************************************/ 00978 inline int gx_createfileinzipa(gxHANDLE handle, struct GX_PARM_CREATEFILEINZIP *cfz) { 00979 assert(cfz); 00980 return gx_call(handle, GX_CALL_CREATEFILEINZIP, cfz); 00981 } 00982 00983 #ifdef __cplusplus 00984 /******************************************************************************/ 00991 inline int gx_createfileinzip(gxHANDLE handle, struct GX_PARM_CREATEFILEINZIP *cfz) { 00992 return gx_createfileinzipa(handle, cfz); 00993 } 00994 #endif 00995 00996 /******************************************************************************/ 01004 inline int gx_writetofileinzip(gxHANDLE handle, const void *buffer, int buflen) { 01005 struct GX_PARM_WRITETOFILEINZIP wfz; 01006 assert(buffer && (buflen > 0)); 01007 wfz.buffer = buffer; 01008 wfz.buflen = buflen; 01009 return gx_call(handle, GX_CALL_WRITETOFILEINZIP, &wfz); 01010 } 01011 01012 /******************************************************************************/ 01018 inline int gx_closefileinzip(gxHANDLE handle) { 01019 return gx_call(handle, GX_CALL_CLOSEFILEINZIP, (void *)0); 01020 } 01021 01022 /******************************************************************************/ 01029 inline int gx_firstfileinzip(gxHANDLE handle, GX_ZIPFILEDETINFOW *finfo) { 01030 assert(finfo); 01031 return gx_call(handle, GX_CALL_FIRSTFILEINZIPW, finfo); 01032 } 01033 01034 /******************************************************************************/ 01041 inline int gx_firstfileinzipa(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01042 return gx_call(handle, GX_CALL_FIRSTFILEINZIP, finfo); 01043 } 01044 01045 #ifdef __cplusplus 01046 /******************************************************************************/ 01053 inline int gx_firstfileinzip(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01054 return gx_firstfileinzipa(handle, finfo); 01055 } 01056 #endif 01057 01058 /******************************************************************************/ 01065 inline int gx_nextfileinzip(gxHANDLE handle, GX_ZIPFILEDETINFOW *finfo) { 01066 return gx_call(handle, GX_CALL_NEXTFILEINZIPW, finfo); 01067 } 01068 01069 /******************************************************************************/ 01076 inline int gx_nextfileinzipa(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01077 return gx_call(handle, GX_CALL_NEXTFILEINZIP, finfo); 01078 } 01079 01080 #ifdef __cplusplus 01081 /******************************************************************************/ 01088 inline int gx_nextfileinzip(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01089 return gx_nextfileinzipa(handle, finfo); 01090 } 01091 #endif 01092 01093 /******************************************************************************/ 01107 inline int gx_locatefileinzip(gxHANDLE handle, GX_ZIPFILEDETINFOW *finfo, 01108 const wchar_t *filename, int casesensitivity) { 01109 struct GX_PARM_LOCATEFILEINZIPW lfz; 01110 assert(filename); 01111 lfz.finfo = finfo; 01112 lfz.filename = filename; 01113 lfz.casesensitivity = casesensitivity; 01114 return gx_call(handle, GX_CALL_LOCATEFILEINZIPW, &lfz); 01115 } 01116 01117 /******************************************************************************/ 01131 inline int gx_locatefileinzipa(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo, 01132 const char *filename, int casesensitivity) { 01133 struct GX_PARM_LOCATEFILEINZIP lfz; 01134 assert(filename); 01135 lfz.finfo = finfo; 01136 lfz.filename = filename; 01137 lfz.casesensitivity = casesensitivity; 01138 return gx_call(handle, GX_CALL_LOCATEFILEINZIP, &lfz); 01139 } 01140 01141 #ifdef __cplusplus 01142 /******************************************************************************/ 01156 inline int gx_locatefileinzip(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo, 01157 const char *filename, int casesensitivity) { 01158 return gx_locatefileinzipa(handle, finfo, filename, casesensitivity); 01159 } 01160 #endif 01161 01162 /******************************************************************************/ 01169 inline int gx_fileinfoinzip(gxHANDLE handle, GX_ZIPFILEDETINFOW *finfo) { 01170 assert(finfo); 01171 return gx_call(handle, GX_CALL_FILEINFOINZIPW, finfo); 01172 } 01173 01174 /******************************************************************************/ 01181 inline int gx_fileinfoinzipa(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01182 assert(finfo); 01183 return gx_call(handle, GX_CALL_FILEINFOINZIP, finfo); 01184 } 01185 01186 #ifdef __cplusplus 01187 /******************************************************************************/ 01194 inline int gx_fileinfoinzip(gxHANDLE handle, GX_ZIPFILEDETINFO *finfo) { 01195 return gx_fileinfoinzipa(handle, finfo); 01196 } 01197 #endif 01198 01199 /******************************************************************************/ 01208 inline int gx_openfileinzip(gxHANDLE handle, int *method, int *level, const wchar_t *password) { 01209 struct GX_PARM_OPENFILEINZIPW ofz; 01210 int st; 01211 ofz.method = ofz.level = 0; 01212 ofz.password = password; 01213 st = gx_call(handle, GX_CALL_OPENFILEINZIPW, &ofz); 01214 if(st) { 01215 if(method) *method = ofz.method; 01216 if(level) *level = ofz.level; 01217 } 01218 return st; 01219 } 01220 01221 /******************************************************************************/ 01230 inline int gx_openfileinzipa(gxHANDLE handle, int *method, int *level, const char *password) { 01231 struct GX_PARM_OPENFILEINZIP ofz; 01232 int st; 01233 ofz.method = ofz.level = 0; 01234 ofz.password = password; 01235 st = gx_call(handle, GX_CALL_OPENFILEINZIP, &ofz); 01236 if(st) { 01237 if(method) *method = ofz.method; 01238 if(level) *level = ofz.level; 01239 } 01240 return st; 01241 } 01242 01243 #ifdef __cplusplus 01244 /******************************************************************************/ 01253 inline int gx_openfileinzip(gxHANDLE handle, int *method, int *level, 01254 const char *password = (const char *)0) { 01255 return gx_openfileinzipa(handle, method, level, password); 01256 } 01257 #endif 01258 01259 /******************************************************************************/ 01267 inline int gx_readfromfileinzip(gxHANDLE handle, void *target, int *tlen) { 01268 struct GX_PARM_READFROMFILEINZIP rfz; 01269 int st; 01270 assert(target && tlen && (*tlen > 0)); 01271 rfz.buffer = target; 01272 rfz.buflen = *tlen; 01273 st = gx_call(handle, GX_CALL_READFROMFILEINZIP, &rfz); 01274 if(st) *tlen = rfz.buflen; 01275 return st; 01276 } 01277 01278 /******************************************************************************/ 01288 inline int gx_calculatezipcrc(gxHANDLE handle, unsigned int *crc, const void *buffer, int buflen) { 01289 struct GX_PARM_CALCULATEZIPCRC czc; 01290 int st; 01291 assert(crc && buffer && (buflen > 0)); 01292 czc.crc = *crc; 01293 czc.buffer = buffer; 01294 czc.buflen = buflen; 01295 st = gx_call(handle, GX_CALL_CALCULATEZIPCRC, &czc); 01296 if(st) *crc = czc.crc; 01297 return st; 01298 } 01299 01300 /******************************************************************************/ 01309 inline int gx_calculatezipcrcd(unsigned int *crc, const void *buffer, int buflen) { 01310 return gx_calculatezipcrc(gx_direct(GX_CALL_GROUP_GX_ZLIB), crc, buffer, buflen); 01311 } 01312 01313 #ifdef __cplusplus 01314 /******************************************************************************/ 01323 inline int gx_calculatezipcrc(unsigned int *crc, const void *buffer, int buflen) { 01324 return gx_calculatezipcrcd(crc, buffer, buflen); 01325 } 01326 #endif 01327 01328 /******************************************************************************/ 01335 inline int gx_getinitialzipcrc(gxHANDLE handle, unsigned int *crc) { 01336 struct GX_PARM_GETINITIALZIPCRC gzc; 01337 int st; 01338 assert(crc); 01339 st = gx_call(handle, GX_CALL_GETINITIALZIPCRC, &gzc); 01340 if(st && crc) *crc = gzc.crc; 01341 return st; 01342 } 01343 01344 /******************************************************************************/ 01350 inline int gx_getinitialzipcrcd(unsigned int *crc) { 01351 return gx_getinitialzipcrc(gx_direct(GX_CALL_GROUP_GX_ZLIB), crc); 01352 } 01353 01354 #ifdef __cplusplus 01355 /******************************************************************************/ 01361 inline int gx_getinitialzipcrc(unsigned int *crc) { 01362 return gx_getinitialzipcrcd(crc); 01363 } 01364 #endif 01365 01366 /******************************************************************************/ 01374 inline int gx_readlexfieldzip(gxHANDLE handle, void *buffer, int *buflen) { 01375 struct GX_PARM_READLEXFIELDZIP rlfz; 01376 int st; 01377 assert(buffer && buflen && (buflen > 0)); 01378 rlfz.buffer = buffer; 01379 rlfz.buflen = *buflen; 01380 st = gx_call(handle, GX_CALL_READLEXFIELDZIP, &rlfz); 01381 if(st) *buflen = rlfz.buflen; 01382 return st; 01383 }; 01384 01385 /******************************************************************************/ 01387 /******************************************************************************/ 01388 01389 #endif 01390 01391 /******************************************************************************/ 01392 01393 #ifdef GX_DOTNET 01394 #pragma managed 01395 #endif 01396 01397 #ifndef NO_GX_CLASSES 01398 01399 /******************************************************************************/ 01404 GX_CLASS gxGZip : public gxHandle { 01405 public: 01407 inline gxGZip() gxFuncThrowsError { 01408 #ifndef GX_DOTNET 01409 if(!gx_openmodule(this, L"gxzlib", L"default")) gxthrow; 01410 #else 01411 GX_GETHANDLE(h); 01412 if(!gx_openmodule(&h, L"gxzlib", L"default")) gxthrow; 01413 _set_handle(h.handle); 01414 #endif 01415 } 01416 01420 inline bool IsValid(void) GX_CONST { 01421 return gxHandle::IsValid(); 01422 } 01423 01424 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01425 01435 inline bool Compress(void *target, int *tgtlen, 01436 const void *source, int srclen, int level) gxFuncThrowsError { 01437 assert(target && tgtlen && (*tgtlen > 0) && source && (srclen > 0)); 01438 bool st = gx_gzcompress(*this, target, tgtlen, 01439 source, srclen, level) ? true : false; 01440 gxcondthrow(!st); 01441 return st; 01442 } 01443 #else 01444 01452 inline gxOutData Compress(gxInData source, int maxlen, int level) gxFuncThrowsError { 01453 GX_GETDATA(source); 01454 GX_GETHANDLE(h); 01455 int targetlen = maxlen ? maxlen : (GX_DATALEN(source)*2+1024); 01456 void *target; 01457 if(!gx_globalalloc(&target, targetlen)) { 01458 GX_FREEDATA(source); 01459 gxthrow; 01460 return GX_PUTDATA_NONE; 01461 } 01462 if(!gx_gzcompress(h, target, &targetlen, GX_DATAPTR(source), GX_DATALEN(source), level)) { 01463 gx_globalfree(target); 01464 GX_FREEDATA(source); 01465 gxthrow; 01466 return GX_PUTDATA_NONE; 01467 } 01468 gxOutData ret = GX_PUTDATA(target, targetlen); 01469 gx_globalfree(target); 01470 GX_FREEDATA(source); 01471 return ret; 01472 } 01473 #endif 01474 01475 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01476 01485 inline bool Uncompress(void *target, int *tgtlen, 01486 const void *source, int srclen) gxFuncThrowsError { 01487 assert(target && tgtlen && (*tgtlen > 0) && source && (srclen > 0)); 01488 bool st = gx_gzuncompress(*this, target, tgtlen, source, srclen) ? true : false; 01489 gxcondthrow(!st); 01490 return st; 01491 } 01492 #else 01493 01500 inline gxOutData Uncompress(gxInData source, int maxlen) gxFuncThrowsError { 01501 GX_GETDATA(source); 01502 GX_GETHANDLE(h); 01503 int targetlen = maxlen; 01504 void *target; 01505 if(!gx_globalalloc(&target, targetlen)) { 01506 GX_FREEDATA(source); 01507 gxthrow; 01508 return GX_PUTDATA_NONE; 01509 } 01510 if(!gx_gzuncompress(h, target, &targetlen, GX_DATAPTR(source), GX_DATALEN(source))) { 01511 gx_globalfree(target); 01512 GX_FREEDATA(source); 01513 gxthrow; 01514 return GX_PUTDATA_NONE; 01515 } 01516 01517 gxOutData ret = GX_PUTDATA(target, targetlen); 01518 gx_globalfree(target); 01519 GX_FREEDATA(source); 01520 return ret; 01521 } 01522 #endif 01523 01524 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01525 01533 inline bool Create(const wchar_t *filename, int level, int strategy) gxFuncThrowsError { 01534 assert(filename); 01535 bool st = gx_creategz(*this, filename, level, strategy) ? true : false; 01536 gxcondthrow(!st); 01537 return st; 01538 } 01539 01548 inline bool Create(const char *filename, int level, int strategy) gxFuncThrowsError { 01549 assert(filename); 01550 bool st = gx_creategz(*this, filename, level, strategy) ? true : false; 01551 gxcondthrow(!st); 01552 return st; 01553 } 01554 #endif 01555 01556 #ifdef GX_UNICODE 01557 01565 inline bool Create(gxInStr filename, int level, int strategy) gxFuncThrowsError { 01566 GX_GETSTRING(_filename, filename); 01567 GX_GETHANDLE(h); 01568 bool st = gx_creategz(h, _filename, level, strategy) ? true : false; 01569 gxcondthrow(!st); 01570 return st; 01571 } 01572 #endif 01573 #ifdef GX_ASCII 01574 01582 inline bool Create(gxInAStr filename, int level, int strategy) gxFuncThrowsError { 01583 GX_GETASTRING(_filename, filename); 01584 GX_GETHANDLE(h); 01585 bool st = gx_creategza(h, _filename, level, strategy) ? true : false; 01586 gxcondthrow(!st); 01587 return st; 01588 } 01589 #endif 01590 01591 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01592 01596 inline bool Open(const wchar_t *filename) gxFuncThrowsError { 01597 assert(filename); 01598 GX_GETHANDLE(h); 01599 bool st = gx_opengz(h, filename) ? true : false; 01600 gxcondthrow(!st); 01601 return st; 01602 } 01603 01608 inline bool Open(const char *filename) gxFuncThrowsError { 01609 assert(filename); 01610 GX_GETHANDLE(h); 01611 bool st = gx_opengza(h, filename) ? true : false; 01612 gxcondthrow(!st); 01613 return st; 01614 } 01615 #endif 01616 01617 #ifdef GX_UNICODE 01618 01622 inline bool Open(gxInStr filename) gxFuncThrowsError { 01623 GX_GETSTRING(_filename, filename); 01624 GX_GETHANDLE(h); 01625 bool st = gx_opengz(h, _filename) ? true : false; 01626 gxcondthrow(!st); 01627 return st; 01628 } 01629 #endif 01630 #ifdef GX_ASCII 01631 01635 inline bool Open(gxInAStr filename) gxFuncThrowsError { 01636 GX_GETASTRING(_filename, filename); 01637 GX_GETHANDLE(h); 01638 bool st = gx_opengza(h, _filename) ? true : false; 01639 gxcondthrow(!st); 01640 return st; 01641 } 01642 #endif 01643 01647 inline bool Close(void) gxFuncThrowsError { 01648 GX_GETHANDLE(h); 01649 bool st = gx_closegz(h) ? true : false; 01650 gxcondthrow(!st); 01651 return st; 01652 } 01653 01654 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01655 01661 inline bool Read(void *buffer, int *buflen) gxFuncThrowsError { 01662 assert(buffer && buflen); 01663 bool st = gx_readgz(*this, buffer, buflen) ? true : false; 01664 gxcondthrow(!st); 01665 return st; 01666 } 01667 #else 01668 01673 inline gxOutData Read(int len) gxFuncThrowsError { 01674 int buflen = len; 01675 void *buffer; 01676 if(!gx_globalalloc(&buffer, buflen)) { 01677 gxthrow; 01678 return GX_PUTDATA_NONE; 01679 } 01680 GX_GETHANDLE(h); 01681 if(!gx_readgz(h, buffer, &buflen)) { 01682 gx_globalfree(buffer); 01683 gxthrow; 01684 return GX_PUTDATA_NONE; 01685 } 01686 gxOutData ret = GX_PUTDATA(buffer, buflen); 01687 gx_globalfree(buffer); 01688 return ret; 01689 } 01690 #endif 01691 01692 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01693 01699 inline bool Write(const void *buffer, int buflen) gxFuncThrowsError { 01700 assert(buffer && buflen); 01701 GX_GETHANDLE(h); 01702 bool st = gx_writegz(h, buffer, buflen) ? true : false; 01703 gxcondthrow(!st); 01704 return st; 01705 } 01706 #else 01707 01711 inline int Write(gxInData buffer) gxFuncThrowsError { 01712 GX_GETDATA(buffer); 01713 GX_GETHANDLE(h); 01714 int l = GX_DATALEN(buffer); 01715 bool st = gx_writegz(h, GX_DATAPTR(buffer), l) ? true : false; 01716 GX_FREEDATA(buffer); 01717 gxcondthrow(!st); 01718 return st ? l : 0; 01719 } 01720 #endif 01721 }; 01722 01723 /******************************************************************************/ 01725 GX_STRUCT gxZipFileInfo { 01726 public: 01727 int tm_sec; 01728 int tm_min; 01729 int tm_hour; 01730 int tm_mday; 01731 int tm_mon; 01732 int tm_year; 01734 int dosdate; 01735 int internal_fa; 01736 int external_fa; 01737 }; 01738 01740 GX_STRUCT gxZipFileDetInfo { 01741 public: 01742 int version; 01743 int version_needed; 01744 int flag; 01745 int method; 01746 unsigned int crc; 01747 int compressed_size; 01748 int uncompressed_size; 01749 int size_filename; 01750 int size_file_extra; 01751 int size_file_comment; 01752 int disk_num_start; 01753 }; 01754 01755 /******************************************************************************/ 01756 #ifdef GX_DOTNET 01757 #define CreateFileOld CreateFile 01758 #undef CreateFile 01759 #endif 01760 01764 GX_CLASS gxZip : public gxHandle { 01765 private: 01766 int _file_method; 01767 int _file_level; 01769 public: 01771 inline gxZip() gxFuncThrowsError { 01772 #ifndef GX_DOTNET 01773 if(!gx_openmodule(this, L"gxzlib", L"default")) gxthrow; 01774 #else 01775 GX_GETHANDLE(h); 01776 if(!gx_openmodule(&h, L"gxzlib", L"default")) gxthrow; 01777 _set_handle(h.handle); 01778 #endif 01779 _file_method = -1; 01780 _file_level = -1; 01781 } 01782 01786 inline bool IsValid(void) GX_CONST { 01787 return gxHandle::IsValid(); 01788 } 01789 01790 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01791 01796 inline bool Create(const wchar_t *filename, int mode) gxFuncThrowsError { 01797 assert(filename); 01798 GX_GETHANDLE(h); 01799 bool st = gx_createzip(h, filename, mode) ? true : false; 01800 gxcondthrow(!st); 01801 return st; 01802 } 01803 01809 inline bool Create(const char *filename, int mode) gxFuncThrowsError { 01810 assert(filename); 01811 GX_GETHANDLE(h); 01812 bool st = gx_createzipa(h, filename, mode) ? true : false; 01813 gxcondthrow(!st); 01814 return st; 01815 } 01816 01817 #endif 01818 #ifdef GX_UNICODE 01819 01824 inline bool Create(gxInStr filename, int mode) gxFuncThrowsError { 01825 GX_GETSTRING(_filename, filename); 01826 GX_GETHANDLE(h); 01827 bool st = gx_createzip(h, _filename, mode) ? true : false; 01828 gxcondthrow(!st); 01829 return st; 01830 } 01831 #endif 01832 #ifdef GX_ASCII 01833 01838 inline bool Create(gxInAStr filename, int mode) gxFuncThrowsError { 01839 GX_GETASTRING(_filename, filename); 01840 GX_GETHANDLE(h); 01841 bool st = gx_createzipa(h, _filename, mode) ? true : false; 01842 gxcondthrow(!st); 01843 return st; 01844 } 01845 #endif 01846 01847 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01848 01852 inline bool Open(const wchar_t *filename) gxFuncThrowsError { 01853 assert(filename); 01854 bool st = gx_openzip(*this, filename) ? true : false; 01855 gxcondthrow(!st); 01856 return st; 01857 } 01858 01863 inline bool Open(const char *filename) gxFuncThrowsError { 01864 assert(filename); 01865 bool st = gx_openzipa(*this, filename) ? true : false; 01866 gxcondthrow(!st); 01867 return st; 01868 } 01869 01870 #endif 01871 #ifdef GX_UNICODE 01872 01876 inline bool Open(gxInStr filename) gxFuncThrowsError { 01877 GX_GETHANDLE(h); 01878 GX_GETSTRING(_filename, filename); 01879 bool st = gx_openzip(h, _filename) ? true : false; 01880 gxcondthrow(!st); 01881 return st; 01882 } 01883 #endif 01884 #ifdef GX_ASCII 01885 01889 inline bool Open(gxInAStr filename) gxFuncThrowsError { 01890 GX_GETHANDLE(h); 01891 GX_GETASTRING(_filename, filename); 01892 bool st = gx_openzipa(h, _filename) ? true : false; 01893 gxcondthrow(!st); 01894 return st; 01895 } 01896 #endif 01897 01898 01899 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01900 01904 inline bool CreateZipInMemory(int mode) gxFuncThrowsError { 01905 GX_GETHANDLE(h); 01906 bool st = gx_createzipinmemory(h, mode) ? true : false; 01907 gxcondthrow(!st); 01908 return st; 01909 } 01910 01916 inline bool GetZipInMemory(void** pbuffer, int* pbuflen) gxFuncThrowsError { 01917 assert(pbuffer); 01918 assert(pbuflen); 01919 GX_GETHANDLE(h); 01920 bool st = gx_getzipinmemory(h, pbuffer, pbuflen) ? true : false; 01921 gxcondthrow(!st); 01922 return st; 01923 } 01924 01930 inline bool OpenZipInMemory(void* buffer, int buflen) gxFuncThrowsError { 01931 assert(buffer); 01932 assert(buflen); 01933 bool st = gx_openzipinmemory(*this, buffer, buflen) ? true : false; 01934 gxcondthrow(!st); 01935 return st; 01936 } 01937 01938 #endif 01939 01940 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 01941 01945 inline bool Close(const wchar_t *comment) gxFuncThrowsError { 01946 bool st = gx_closezip(*this, comment) ? true : false; 01947 gxcondthrow(!st); 01948 return st; 01949 } 01950 01955 inline bool Close(const char *comment) gxFuncThrowsError { 01956 bool st = gx_closezip(*this, comment) ? true : false; 01957 gxcondthrow(!st); 01958 return st; 01959 } 01960 #endif 01961 01962 #ifdef GX_UNICODE 01963 01967 inline bool Close(gxInStr comment) gxFuncThrowsError { 01968 GX_GETHANDLE(h); 01969 GX_GETSTRING(_comment, comment); 01970 bool st = gx_closezip(h, _comment) ? true : false; 01971 gxcondthrow(!st); 01972 return st; 01973 } 01974 #endif 01975 #ifdef GX_ASCII 01976 01980 inline bool Close(gxInAStr comment) gxFuncThrowsError { 01981 GX_GETHANDLE(h); 01982 GX_GETASTRING(_comment, comment); 01983 bool st = gx_closezipa(h, _comment) ? true : false; 01984 gxcondthrow(!st); 01985 return st; 01986 } 01987 #endif 01988 01992 inline bool Close(void) gxFuncThrowsError { 01993 GX_GETHANDLE(h); 01994 bool st = gx_closezipa(h, (const char *)0) ? true : false; 01995 gxcondthrow(!st); 01996 return st; 01997 } 01998 01999 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02000 02004 inline bool GetInfo(GX_PARM_GETZIPINFO *info) gxFuncThrowsError { 02005 assert(info); 02006 bool st = gx_getzipinfo(*this, info) ? true : false; 02007 gxcondthrow(!st); 02008 return st; 02009 } 02010 #endif 02011 02016 inline int GetNEntries(void) gxFuncThrowsError { 02017 GX_GETHANDLE(h); 02018 GX_PARM_GETZIPINFO info; 02019 info.nentries = -1; 02020 if(!gx_getzipinfo(h, &info)) gxthrow; 02021 return info.nentries; 02022 } 02023 02028 inline int GetCommentLength(void) gxFuncThrowsError { 02029 GX_GETHANDLE(h); 02030 GX_PARM_GETZIPINFO info; 02031 info.commentlen = -1; 02032 if(!gx_getzipinfo(h, &info)) gxthrow; 02033 return info.commentlen; 02034 } 02035 02036 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02037 02043 inline bool GetComment(wchar_t *target, int *tlen) gxFuncThrowsError { 02044 assert(target && tlen && (*tlen >= 0)); 02045 bool st = gx_getzipcomment(*this, target, tlen) ? true : false; 02046 gxcondthrow(!st); 02047 return st; 02048 } 02049 02056 inline bool GetComment(char *target, int *tlen) gxFuncThrowsError { 02057 assert(target && tlen && (*tlen >= 0)); 02058 bool st = gx_getzipcomment(*this, target, tlen) ? true : false; 02059 gxcondthrow(!st); 02060 return st; 02061 } 02062 #endif 02063 02064 #ifdef GX_UNICODE 02065 02069 inline gxOutStr GetComment(void) gxFuncThrowsError { 02070 int buflen = GetCommentLength(); 02071 if(buflen <= 0) return GX_PUTSTRING_NONE; 02072 wchar_t *buffer; 02073 if(!gx_globalalloc((void **)(void *)&buffer, sizeof(wchar_t)*(buflen+1))) { 02074 gxthrow; 02075 return GX_PUTSTRING_NONE; 02076 } 02077 GX_GETHANDLE(h); 02078 buflen++; 02079 if(!gx_getzipcomment(h, buffer, &buflen)) { 02080 gx_globalfree(buffer); 02081 gxthrow; 02082 return GX_PUTSTRING_NONE; 02083 } 02084 buffer[buflen-1] = 0; 02085 gxOutStr ret = GX_PUTSTRING(buffer); 02086 gx_globalfree(buffer); 02087 return ret; 02088 } 02089 #endif 02090 #ifdef GX_ASCII 02091 02095 inline gxOutAStr GetCommentA(void) gxFuncThrowsError { 02096 int buflen = GetCommentLength(); 02097 if(buflen <= 0) return GX_PUTASTRING_NONE; 02098 char *buffer; 02099 if(!gx_globalalloc((void **)(void *)&buffer, buflen+1)) { 02100 gxthrow; 02101 return GX_PUTASTRING_NONE; 02102 } 02103 GX_GETHANDLE(h); 02104 if(!gx_getzipcommenta(h, buffer, &buflen)) { 02105 gx_globalfree(buffer); 02106 gxthrow; 02107 return GX_PUTASTRING_NONE; 02108 } 02109 buffer[buflen] = 0; 02110 gxOutAStr ret = GX_PUTASTRING(buffer); 02111 gx_globalfree(buffer); 02112 return ret; 02113 } 02114 #endif 02115 02116 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02117 02121 inline bool CreateFile(GX_PARM_CREATEFILEINZIPW *cfz) gxFuncThrowsError { 02122 assert(cfz); 02123 bool st = gx_createfileinzip(*this, cfz) ? true : false; 02124 gxcondthrow(!st); 02125 return st; 02126 } 02127 02132 inline bool CreateFile(GX_PARM_CREATEFILEINZIP *cfz) gxFuncThrowsError { 02133 assert(cfz); 02134 GX_GETHANDLE(h); 02135 bool st = gx_createfileinzipa(h, cfz) ? true : false; 02136 gxcondthrow(!st); 02137 return st; 02138 } 02139 #endif 02140 02141 #if defined(GX_DOTNET) || defined(GX_SWIG) 02142 02143 #ifdef GX_UNICODE 02144 02158 inline bool CreateFile(gxInStr filename, int level, int strategy, gxInStr comment, 02159 gxZipFileInfo GX_REF_STRUCT(info), gxInStr password, unsigned int crc, 02160 gxInData localexf, gxInData globalexf) 02161 { 02162 02163 GX_ZIPFILEINFO _info; 02164 GX_PARM_CREATEFILEINZIPW cfz; 02165 memset(&cfz, 0, sizeof(cfz)); 02166 02167 _info.tm_sec = info GX_MS tm_sec; 02168 _info.tm_min = info GX_MS tm_min; 02169 _info.tm_hour = info GX_MS tm_hour; 02170 _info.tm_mday = info GX_MS tm_mday; 02171 _info.tm_mon = info GX_MS tm_mon; 02172 _info.tm_year = info GX_MS tm_year; 02173 _info.dosdate = info GX_MS dosdate; 02174 _info.internal_fa = info GX_MS internal_fa; 02175 _info.external_fa = info GX_MS external_fa; 02176 cfz.info = &_info; 02177 02178 GX_GETSTRING(_filename, filename); 02179 cfz.filename = _filename; 02180 cfz.level = level; 02181 cfz.strategy = strategy; 02182 GX_GETSTRING(_comment, comment); 02183 cfz.comment = _comment; 02184 GX_GETSTRING(_password, password); 02185 cfz.password = (_password && *_password) ? _password : 0; 02186 cfz.crc = crc; 02187 GX_GETDATA(localexf); 02188 GX_GETDATA(globalexf); 02189 cfz.exflocal = GX_DATAPTR(localexf); 02190 cfz.exflocal_len = GX_DATALEN(localexf); 02191 cfz.exfglobal = GX_DATAPTR(globalexf); 02192 cfz.exfglobal_len = GX_DATALEN(globalexf); 02193 GX_GETHANDLE(h); 02194 bool st = gx_createfileinzip(h, &cfz) ? true : false; 02195 GX_FREEDATA(localexf); 02196 GX_FREEDATA(globalexf); 02197 gxcondthrow(!st); 02198 return st; 02199 } 02200 #endif // GX_UNICODE 02201 02202 #ifdef GX_ASCII 02203 02217 inline bool CreateFile(gxInAStr filename, int level, int strategy, 02218 gxInAStr comment, gxZipFileInfo GX_REF_STRUCT(info), 02219 gxInAStr password, unsigned int crc, 02220 gxInData localexf, gxInData globalexf) { 02221 GX_ZIPFILEINFO _info; 02222 GX_PARM_CREATEFILEINZIP cfz; 02223 memset(&cfz, 0, sizeof(cfz)); 02224 _info.tm_sec = info.tm_sec; 02225 _info.tm_min = info.tm_min; 02226 _info.tm_hour = info.tm_hour; 02227 _info.tm_mday = info.tm_mday; 02228 _info.tm_mon = info.tm_mon; 02229 _info.tm_year = info.tm_year; 02230 _info.dosdate = info.dosdate; 02231 _info.internal_fa = info.internal_fa; 02232 _info.external_fa = info.external_fa; 02233 cfz.info = &_info; 02234 GX_GETASTRING(_filename, filename); 02235 cfz.filename = _filename; 02236 cfz.level = level; 02237 cfz.strategy = strategy; 02238 GX_GETASTRING(_comment, comment); 02239 cfz.comment = _comment; 02240 GX_GETASTRING(_password, password); 02241 cfz.password = (_password && *_password) ? _password : 0; 02242 cfz.crc = crc; 02243 GX_GETDATA(localexf); 02244 GX_GETDATA(globalexf); 02245 cfz.exflocal = GX_DATAPTR(localexf); 02246 cfz.exflocal_len = GX_DATALEN(localexf); 02247 cfz.exfglobal = GX_DATAPTR(globalexf); 02248 cfz.exfglobal_len = GX_DATALEN(globalexf); 02249 GX_GETHANDLE(h); 02250 bool st = gx_createfileinzipa(h, &cfz) ? true : false; 02251 GX_FREEDATA(localexf); 02252 GX_FREEDATA(globalexf); 02253 gxcondthrow(!st); 02254 return st; 02255 } 02256 #endif // GX_ASCII 02257 02258 #endif // defined(GX_DOTNET) && defined(GX_SWIG) 02259 02260 #ifdef GX_UNICODE 02261 02269 inline bool CreateFile(gxInStr filename, int level, int strategy, 02270 gxInStr comment, gxZipFileInfo GX_REF_STRUCT(info)) { 02271 02272 GX_ZIPFILEINFO _info; 02273 GX_PARM_CREATEFILEINZIPW cfz; 02274 memset(&cfz, 0, sizeof(cfz)); 02275 02276 _info.tm_sec = info GX_MS tm_sec; 02277 _info.tm_min = info GX_MS tm_min; 02278 _info.tm_hour = info GX_MS tm_hour; 02279 _info.tm_mday = info GX_MS tm_mday; 02280 _info.tm_mon = info GX_MS tm_mon; 02281 _info.tm_year = info GX_MS tm_year; 02282 _info.dosdate = info GX_MS dosdate; 02283 _info.internal_fa = info GX_MS internal_fa; 02284 _info.external_fa = info GX_MS external_fa; 02285 cfz.info = &_info; 02286 02287 GX_GETSTRING(_filename, filename); 02288 cfz.filename = _filename; 02289 cfz.level = level; 02290 cfz.strategy = strategy; 02291 GX_GETSTRING(_comment, comment); 02292 cfz.comment = _comment; 02293 GX_GETHANDLE(h); 02294 bool st = gx_createfileinzip(h, &cfz) ? true : false; 02295 gxcondthrow(!st); 02296 return st; 02297 } 02298 #endif // GX_UNICODE 02299 02300 #ifdef GX_ASCII 02301 02309 inline bool CreateFile(gxInAStr filename, int level, int strategy, 02310 gxInAStr comment, gxZipFileInfo GX_REF_STRUCT(info)) { 02311 GX_ZIPFILEINFO _info; 02312 GX_PARM_CREATEFILEINZIP cfz; 02313 memset(&cfz, 0, sizeof(cfz)); 02314 _info.tm_sec = info.tm_sec; 02315 _info.tm_min = info.tm_min; 02316 _info.tm_hour = info.tm_hour; 02317 _info.tm_mday = info.tm_mday; 02318 _info.tm_mon = info.tm_mon; 02319 _info.tm_year = info.tm_year; 02320 _info.dosdate = info.dosdate; 02321 _info.internal_fa = info.internal_fa; 02322 _info.external_fa = info.external_fa; 02323 cfz.info = &_info; 02324 GX_GETASTRING(_filename, filename); 02325 cfz.filename = _filename; 02326 cfz.level = level; 02327 cfz.strategy = strategy; 02328 GX_GETASTRING(_comment, comment); 02329 cfz.comment = _comment; 02330 GX_GETHANDLE(h); 02331 bool st = gx_createfileinzipa(h, &cfz) ? true : false; 02332 gxcondthrow(!st); 02333 return st; 02334 } 02335 #endif // GX_ASCII 02336 02337 #if !defined(GX_DOTNET) && !defined(GX_SWIG) 02338 02345 inline bool CreateFile(const wchar_t *filename, int level, int strategy, 02346 const wchar_t *comment) { 02347 02348 GX_PARM_CREATEFILEINZIPW cfz; 02349 memset(&cfz, 0, sizeof(cfz)); 02350 cfz.filename = filename; 02351 cfz.level = level; 02352 cfz.strategy = strategy; 02353 cfz.comment = comment; 02354 bool st = gx_createfileinzip(*this, &cfz) ? true : false; 02355 gxcondthrow(!st); 02356 return st; 02357 } 02358 02366 inline bool CreateFile(const char *filename, int level, int strategy, 02367 const char *comment) { 02368 02369 GX_PARM_CREATEFILEINZIP cfz; 02370 memset(&cfz, 0, sizeof(cfz)); 02371 cfz.filename = filename; 02372 cfz.level = level; 02373 cfz.strategy = strategy; 02374 cfz.comment = comment; 02375 bool st = gx_createfileinzipa(*this, &cfz) ? true : false; 02376 gxcondthrow(!st); 02377 return st; 02378 } 02379 #endif 02380 02381 02382 #ifdef GX_UNICODE 02383 02390 inline bool CreateFile(gxInStr filename, int level, int strategy, 02391 gxInStr comment) { 02392 02393 GX_PARM_CREATEFILEINZIPW cfz; 02394 memset(&cfz, 0, sizeof(cfz)); 02395 GX_GETSTRING(_filename, filename); 02396 cfz.filename = _filename; 02397 cfz.level = level; 02398 cfz.strategy = strategy; 02399 GX_GETSTRING(_comment, comment); 02400 cfz.comment = _comment; 02401 GX_GETHANDLE(h); 02402 bool st = gx_createfileinzip(h, &cfz) ? true : false; 02403 gxcondthrow(!st); 02404 return st; 02405 } 02406 #endif // GX_UNICODE 02407 02408 #ifdef GX_ASCII 02409 02416 inline bool CreateFile(gxInAStr filename, int level, int strategy, 02417 gxInAStr comment) { 02418 02419 GX_PARM_CREATEFILEINZIP cfz; 02420 memset(&cfz, 0, sizeof(cfz)); 02421 GX_GETASTRING(_filename, filename); 02422 cfz.filename = _filename; 02423 cfz.level = level; 02424 cfz.strategy = strategy; 02425 GX_GETASTRING(_comment, comment); 02426 cfz.comment = _comment; 02427 GX_GETHANDLE(h); 02428 bool st = gx_createfileinzipa(h, &cfz) ? true : false; 02429 gxcondthrow(!st); 02430 return st; 02431 } 02432 #endif // GX_ASCII 02433 02434 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02435 02440 inline bool WriteToFile(const void *buffer, int buflen) gxFuncThrowsError { 02441 assert(buffer && (buflen >= 0)); 02442 bool st = gx_writetofileinzip(*this, buffer, buflen) ? true : false; 02443 gxcondthrow(!st); 02444 return st; 02445 } 02446 #else 02447 02451 inline bool WriteToFile(gxInData data) gxFuncThrowsError { 02452 GX_GETDATA(data); 02453 GX_GETHANDLE(h); 02454 bool st = gx_writetofileinzip(h, GX_DATAPTR(data), GX_DATALEN(data)) ? 02455 true : false; 02456 GX_FREEDATA(data); 02457 gxcondthrow(!st); 02458 return st; 02459 } 02460 #endif 02461 02465 inline bool CloseFile(void) gxFuncThrowsError { 02466 GX_GETHANDLE(h); 02467 bool st = gx_closefileinzip(h) ? true : false; 02468 gxcondthrow(!st); 02469 return st; 02470 } 02471 02472 #if !defined(GX_DOTNET) && !defined(GX_SWIG) 02473 02477 inline bool FirstFile(GX_ZIPFILEDETINFOW *finfo) { 02478 assert(finfo); 02479 return gx_firstfileinzip(*this, finfo) ? true : false; 02480 } 02481 02486 inline bool FirstFile(GX_ZIPFILEDETINFO *finfo) { 02487 assert(finfo); 02488 return gx_firstfileinzip(*this, finfo) ? true : false; 02489 } 02490 #endif 02491 02495 inline bool FirstFile(void) { 02496 GX_GETHANDLE(h); 02497 return gx_firstfileinzip(h, (GX_ZIPFILEDETINFO *)0) ? true : false; 02498 } 02499 02500 #if !defined(GX_DOTNET) && !defined(GX_SWIG) 02501 02505 inline bool NextFile(GX_ZIPFILEDETINFOW *finfo) { 02506 assert(finfo); 02507 return gx_nextfileinzip(*this, finfo) ? true : false; 02508 } 02509 02514 inline bool NextFile(GX_ZIPFILEDETINFO *finfo) { 02515 assert(finfo); 02516 return gx_nextfileinzip(*this, finfo) ? true : false; 02517 } 02518 #endif 02519 02523 inline bool NextFile(void) { 02524 GX_GETHANDLE(h); 02525 return gx_nextfileinzip(h, (GX_ZIPFILEDETINFO *)0) ? true : false; 02526 } 02527 02528 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02529 02540 inline bool LocateFile(GX_ZIPFILEDETINFOW *finfo, const wchar_t *filename, 02541 int casesensitivity = 0) gxFuncThrowsError { 02542 assert(finfo); 02543 assert(filename); 02544 return gx_locatefileinzip(*this, finfo, filename, casesensitivity) ? 02545 true : false; 02546 } 02547 02559 inline bool LocateFile(GX_ZIPFILEDETINFO *finfo, const char *filename, 02560 int casesensitivity = 0) gxFuncThrowsError { 02561 assert(finfo); 02562 assert(filename); 02563 return gx_locatefileinzipa(*this, finfo, filename, casesensitivity) ? 02564 true : false; 02565 } 02566 #endif 02567 02568 #ifdef GX_UNICODE 02569 02579 inline bool LocateFile(gxInStr filename, int casesensitivity GX_DEFARG(0)) gxFuncThrowsError { 02580 GX_GETSTRING(_filename, filename); 02581 GX_GETHANDLE(h); 02582 return gx_locatefileinzip(h, (GX_ZIPFILEDETINFOW *)0, _filename, 02583 casesensitivity) ? true : false; 02584 } 02585 #endif 02586 #ifdef GX_ASCII 02587 02597 inline bool LocateFile(gxInAStr filename, int casesensitivity = 0) gxFuncThrowsError { 02598 GX_GETASTRING(_filename, filename); 02599 GX_GETHANDLE(h); 02600 return gx_locatefileinzipa(h, (GX_ZIPFILEDETINFO *)0, _filename, 02601 casesensitivity) ? true : false; 02602 } 02603 #endif 02604 02605 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02606 02610 inline bool FileInfo(GX_ZIPFILEDETINFO *finfo) gxFuncThrowsError { 02611 assert(finfo); 02612 bool st = gx_fileinfoinzip(*this, finfo) ? true : false; 02613 gxcondthrow(!st); 02614 return st; 02615 } 02616 02621 inline bool FileInfo(GX_ZIPFILEDETINFOW *finfo) gxFuncThrowsError { 02622 assert(finfo); 02623 bool st = gx_fileinfoinzip(*this, finfo) ? true : false; 02624 gxcondthrow(!st); 02625 return st; 02626 } 02627 #endif 02628 02633 inline gxZipFileInfo GetFileInfo(void) gxFuncThrowsError { 02634 GX_ZIPFILEDETINFO info; 02635 memset(&info, 0, sizeof(info)); 02636 gxZipFileInfo ret; 02637 memset(&ret, 0, sizeof(ret)); 02638 GX_GETHANDLE(h); 02639 if(gx_fileinfoinzip(h, &info)) { 02640 ret.tm_sec = info.tm_sec; 02641 ret.tm_min = info.tm_min; 02642 ret.tm_hour = info.tm_hour; 02643 ret.tm_mday = info.tm_mday; 02644 ret.tm_mon = info.tm_mon; 02645 ret.tm_year = info.tm_year; 02646 ret.dosdate = info.dosdate; 02647 ret.internal_fa = info.internal_fa; 02648 ret.external_fa = info.external_fa; 02649 } else { 02650 gxthrow; 02651 } 02652 return ret; 02653 } 02654 02659 inline gxZipFileDetInfo GetFileDetInfo(void) gxFuncThrowsError { 02660 GX_ZIPFILEDETINFO info; 02661 memset(&info, 0, sizeof(info)); 02662 gxZipFileDetInfo ret; 02663 memset(&ret, 0, sizeof(ret)); 02664 GX_GETHANDLE(h); 02665 if(gx_fileinfoinzip(h, &info)) { 02666 ret.version = info.version; 02667 ret.version_needed = info.version_needed; 02668 ret.flag = info.flag; 02669 ret.method = info.method; 02670 ret.crc = info.crc; 02671 ret.compressed_size = info.compressed_size; 02672 ret.uncompressed_size = info.uncompressed_size; 02673 ret.size_filename = info.size_filename; 02674 ret.size_file_extra = info.size_file_extra; 02675 ret.size_file_comment = info.size_file_comment; 02676 ret.disk_num_start = info.disk_num_start; 02677 } else { 02678 gxthrow; 02679 } 02680 return ret; 02681 } 02682 02683 #ifdef GX_UNICODE 02684 02688 inline gxOutStr GetFileName(void) { 02689 GX_ZIPFILEDETINFOW info; 02690 memset(&info, 0, sizeof(info)); 02691 GX_GETHANDLE(h); 02692 if(!gx_fileinfoinzip(h, &info)) { 02693 gxthrow; 02694 return GX_PUTSTRING_NONE; 02695 } 02696 wchar_t *filename; 02697 if(!gx_globalalloc((void **)(void *)&filename, sizeof(wchar_t)*(info.size_filename+1))) { 02698 gxthrow; 02699 return GX_PUTSTRING_NONE; 02700 } 02701 info.filename = filename; 02702 info.filename_len = info.size_filename+1; 02703 if(!gx_fileinfoinzip(h, &info)) { 02704 gx_globalfree(filename); 02705 gxthrow; 02706 return GX_PUTSTRING_NONE; 02707 } 02708 filename[info.size_filename] = 0; 02709 gxOutStr ret = GX_PUTSTRING(filename); 02710 gx_globalfree(filename); 02711 return ret; 02712 } 02713 #endif 02714 #ifdef GX_ASCII 02715 02719 inline gxOutAStr GetFileNameA(void) { 02720 GX_ZIPFILEDETINFO info; 02721 memset(&info, 0, sizeof(info)); 02722 GX_GETHANDLE(h); 02723 if(!gx_fileinfoinzipa(h, &info)) { 02724 gxthrow; 02725 return GX_PUTASTRING_NONE; 02726 } 02727 char *filename; 02728 if(!gx_globalalloc((void **)(void *)&filename, info.size_filename+1)) { 02729 gxthrow; 02730 return GX_PUTASTRING_NONE; 02731 } 02732 info.filename = filename; 02733 info.filename_len = info.size_filename+1; 02734 if(!gx_fileinfoinzipa(h, &info)) { 02735 gx_globalfree(filename); 02736 gxthrow; 02737 return GX_PUTASTRING_NONE; 02738 } 02739 filename[info.size_filename] = 0; 02740 gxOutAStr ret = GX_PUTASTRING(filename); 02741 gx_globalfree(filename); 02742 return ret; 02743 } 02744 #endif 02745 02746 #ifdef GX_UNICODE 02747 02751 inline gxOutStr GetFileComment(void) { 02752 GX_ZIPFILEDETINFOW info; 02753 memset(&info, 0, sizeof(info)); 02754 GX_GETHANDLE(h); 02755 if(!gx_fileinfoinzip(h, &info)) { 02756 gxthrow; 02757 return GX_PUTSTRING_NONE; 02758 } 02759 wchar_t *comment; 02760 if(!gx_globalalloc((void **)(void *)&comment, sizeof(wchar_t)*(info.size_file_comment+1))) { 02761 gxthrow; 02762 return GX_PUTSTRING_NONE; 02763 } 02764 info.comment = comment; 02765 info.comment_len = info.size_file_comment+1; 02766 if(!gx_fileinfoinzip(h, &info)) { 02767 gx_globalfree(comment); 02768 gxthrow; 02769 return GX_PUTSTRING_NONE; 02770 } 02771 comment[info.size_file_comment] = 0; 02772 gxOutStr ret = GX_PUTSTRING(comment); 02773 gx_globalfree(comment); 02774 return ret; 02775 } 02776 #endif 02777 #ifdef GX_ASCII 02778 02782 inline gxOutAStr GetFileCommentA(void) { 02783 GX_ZIPFILEDETINFO info; 02784 memset(&info, 0, sizeof(info)); 02785 GX_GETHANDLE(h); 02786 if(!gx_fileinfoinzipa(h, &info)) { 02787 gxthrow; 02788 return GX_PUTASTRING_NONE; 02789 } 02790 char *comment; 02791 if(!gx_globalalloc((void **)(void *)&comment, info.size_file_comment+1)) { 02792 gxthrow; 02793 return GX_PUTASTRING_NONE; 02794 } 02795 info.comment = comment; 02796 info.comment_len = info.size_file_comment+1; 02797 if(!gx_fileinfoinzipa(h, &info)) { 02798 gx_globalfree(comment); 02799 gxthrow; 02800 return GX_PUTASTRING_NONE; 02801 } 02802 comment[info.size_file_comment] = 0; 02803 gxOutAStr ret = GX_PUTASTRING(comment); 02804 gx_globalfree(comment); 02805 return ret; 02806 } 02807 #endif 02808 02809 #if defined(GX_DOTNET) || defined(GX_SWIG) 02810 02814 inline gxOutData GetFileGlobalExtraField(void) { 02815 GX_ZIPFILEDETINFO info; 02816 memset(&info, 0, sizeof(info)); 02817 GX_GETHANDLE(h); 02818 if(!gx_fileinfoinzipa(h, &info)) { 02819 gxthrow; 02820 return GX_PUTDATA_NONE; 02821 } 02822 void *gextrafield; 02823 if(!gx_globalalloc(&gextrafield, info.size_file_extra)) { 02824 gxthrow; 02825 return GX_PUTDATA_NONE; 02826 } 02827 info.gextrafield = gextrafield; 02828 info.gextrafield_len = info.size_file_extra; 02829 if(!gx_fileinfoinzipa(h, &info)) { 02830 gx_globalfree(gextrafield); 02831 gxthrow; 02832 return GX_PUTDATA_NONE; 02833 } 02834 gxOutData ret = GX_PUTDATA(gextrafield, info.gextrafield_len); 02835 gx_globalfree(gextrafield); 02836 return ret; 02837 } 02838 #endif 02839 02840 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02841 02847 inline bool OpenFile(int *method, int *level, const wchar_t *password) gxFuncThrowsError { 02848 bool st = gx_openfileinzip(*this, &_file_method, &_file_level, password) ? true : false; 02849 gxcondthrow(!st); 02850 if(st) { 02851 if(method) *method = _file_method; 02852 if(level) *level = _file_level; 02853 } 02854 return st; 02855 } 02856 02863 inline bool OpenFile(int *method, int *level = (int *)0, const char *password = (const char *)0) gxFuncThrowsError { 02864 bool st = gx_openfileinzipa(*this, &_file_method, &_file_level, password) ? true : false; 02865 gxcondthrow(!st); 02866 if(st) { 02867 if(method) *method = _file_method; 02868 if(level) *level = _file_level; 02869 } 02870 return st; 02871 } 02872 #endif 02873 02876 inline bool OpenFile(void) gxFuncThrowsError { 02877 GX_GETHANDLE(h); 02878 int _fm = _file_method; 02879 int _fl = _file_level; 02880 bool st = gx_openfileinzipa(h, &_fm, &_fl, (const char *)0) ? true : false; 02881 _file_method = _fm; 02882 _file_level = _fl; 02883 gxcondthrow(!st); 02884 return st; 02885 } 02886 02887 #ifdef GX_UNICODE 02888 02892 inline bool OpenFile(gxInStr password) gxFuncThrowsError { 02893 GX_GETSTRING(_password, password); 02894 GX_GETHANDLE(h); 02895 int _fm = _file_method; 02896 int _fl = _file_level; 02897 bool st = gx_openfileinzip(h, &_fm, &_fl, _password) ? true : false; 02898 gxcondthrow(!st); 02899 _file_method = _fm; 02900 _file_level = _fl; 02901 return st; 02902 } 02903 #endif 02904 #ifdef GX_ASCII 02905 02909 inline bool OpenFile(gxInAStr password) gxFuncThrowsError { 02910 GX_GETASTRING(_password, password); 02911 bool st = gx_openfileinzipa(*this, &_file_method, &_file_level, _password) ? true : false; 02912 gxcondthrow(!st); 02913 return st; 02914 } 02915 #endif 02916 02920 inline int GetFileMethod(void) gxFuncThrowsError { 02921 return _file_method; 02922 } 02923 02927 inline int GetFileLevel(void) gxFuncThrowsError { 02928 return _file_level; 02929 } 02930 02931 #if !defined (GX_SWIG) && !defined(GX_DOTNET) 02932 02937 inline bool ReadFromFile(void *target, int *tlen) gxFuncThrowsError { 02938 assert(target && tlen && (*tlen >= 0)); 02939 bool st = gx_readfromfileinzip(*this, target, tlen) ? true : false; 02940 gxcondthrow(!st); 02941 return st; 02942 } 02943 #else 02944 02949 inline gxOutData ReadFromFile(int len) gxFuncThrowsError { 02950 void *target; 02951 if(!gx_globalalloc(&target, len)) { 02952 gxthrow; 02953 return GX_PUTDATA_NONE; 02954 } 02955 int tlen = len; 02956 GX_GETHANDLE(h); 02957 bool st = gx_readfromfileinzip(h, target, &tlen) ? true : false; 02958 if(!st) { 02959 gx_globalfree(target); 02960 gxthrow; 02961 return GX_PUTDATA_NONE; 02962 } 02963 gxOutData ret = GX_PUTDATA(target, tlen); 02964 gx_globalfree(target); 02965 return ret; 02966 } 02967 #endif 02968 02969 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 02970 02976 inline bool CalculateCRC(unsigned int *crc, const void *buffer, int buflen) gxFuncThrowsError { 02977 assert(crc && buffer && (buflen >= 0)); 02978 bool st = gx_calculatezipcrc(*this, crc, buffer, buflen) ? true : false; 02979 gxcondthrow(!st); 02980 return st; 02981 } 02982 #else 02983 02989 inline unsigned int CalculateCRC(unsigned int initialcrc, gxInData buffer) gxFuncThrowsError { 02990 unsigned int ret = initialcrc; 02991 GX_GETHANDLE(h); 02992 GX_GETDATA(buffer); 02993 bool st = gx_calculatezipcrc(h, &ret, GX_DATAPTR(buffer), GX_DATALEN(buffer)) ? true : false; 02994 GX_FREEDATA(buffer); 02995 gxcondthrow(!st); 02996 return ret; 02997 } 02998 #endif 02999 03000 #if !defined(GX_SWIG) && !defined(GX_DOTNET) 03001 03005 inline bool GetInitialCRC(unsigned int *crc) gxFuncThrowsError { 03006 assert(crc); 03007 bool st = gx_getinitialzipcrc(*this, crc) ? true : false; 03008 gxcondthrow(!st); 03009 return st; 03010 } 03011 #endif 03012 03017 inline unsigned int GetInitialCRC(void) gxFuncThrowsError { 03018 unsigned int ret = 0; 03019 GX_GETHANDLE(h); 03020 if(!gx_getinitialzipcrc(h, &ret)) gxthrow; 03021 return ret; 03022 } 03023 03024 #if !defined(GX_DOTNET) && !defined(GX_SWIG) 03025 03030 inline bool ReadLocalExtraField(void *buffer, int *buflen) gxFuncThrowsError { 03031 assert(buffer && buflen && (*buflen >= 0)); 03032 bool st = gx_readlexfieldzip(*this, buffer, buflen) ? true : false; 03033 gxcondthrow(!st); 03034 return st; 03035 } 03036 #else 03037 03042 inline gxOutData ReadLocalExtraField(int maxlen) { 03043 GX_GETHANDLE(h); 03044 void *lextrafield; 03045 if(!gx_globalalloc(&lextrafield, maxlen)) { 03046 gxthrow; 03047 return GX_PUTDATA_NONE; 03048 } 03049 int lextrafield_len = maxlen; 03050 if(!gx_readlexfieldzip(h, lextrafield, &lextrafield_len)) { 03051 gx_globalfree(lextrafield); 03052 gxthrow; 03053 return GX_PUTDATA_NONE; 03054 } 03055 gxOutData ret = GX_PUTDATA(lextrafield, lextrafield_len); 03056 gx_globalfree(lextrafield); 03057 return ret; 03058 } 03059 #endif 03060 03061 }; 03062 #ifdef GX_DOTNET 03063 #define CreateFile CreateFileOld 03064 #undef CreateFileOld 03065 #endif 03066 /******************************************************************************/ 03067 #endif // NO_GX_CLASSES 03068 /******************************************************************************/ 03069 #ifdef GX_NAMESPACES 03070 } 03071 #endif 03072 /******************************************************************************/ 03073 #endif // GXZLIB_INCL 03074 /******************************************************************************/