2008-06-23 15:57 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbziparch/common.mak
- contrib/hbziparch/zip.h
- contrib/hbziparch/unzip.h
* contrib/hbziparch/hbziparc.c
* contrib/hbziparch/hbziparc.h
* contrib/hbziparch/hbzipcom.cpp
* contrib/hbziparch/hbzipnew.cpp
* Further cleanup.
; Now the Harbour part compiles cleanly, except the
recently added HB_FUNC_EXIT( HBZIPCLEANUP ).
; I have a version ready using the unmodified sources
of the latest ZipArchive version. Waiting for
testers or test code.
This commit is contained in:
@@ -8,18 +8,33 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2008-06-23 15:57 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/hbziparch/common.mak
|
||||
- contrib/hbziparch/zip.h
|
||||
- contrib/hbziparch/unzip.h
|
||||
* contrib/hbziparch/hbziparc.c
|
||||
* contrib/hbziparch/hbziparc.h
|
||||
* contrib/hbziparch/hbzipcom.cpp
|
||||
* contrib/hbziparch/hbzipnew.cpp
|
||||
* Further cleanup.
|
||||
; Now the Harbour part compiles cleanly, except the
|
||||
recently added HB_FUNC_EXIT( HBZIPCLEANUP ).
|
||||
; I have a version ready using the unmodified sources
|
||||
of the latest ZipArchive version. Waiting for
|
||||
testers or test code.
|
||||
|
||||
2008-06-23 14:08 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
- hbziparch/make_b32_dll.bat
|
||||
- hbziparch/make_b32_dll.mak
|
||||
- hbziparch/doc
|
||||
* hbziparch/Makefile
|
||||
* hbziparch/common.mak
|
||||
* hbziparch/hbziparc.c
|
||||
* hbziparch/hbziparc.h
|
||||
- hbziparch/zipcomp.cpp
|
||||
+ hbziparch/hbzipcom.cpp
|
||||
- hbziparch/zipnew.cpp
|
||||
+ hbziparch/hbzipnew.cpp
|
||||
- contrib/hbziparch/make_b32_dll.bat
|
||||
- contrib/hbziparch/make_b32_dll.mak
|
||||
- contrib/hbziparch/doc
|
||||
* contrib/hbziparch/Makefile
|
||||
* contrib/hbziparch/common.mak
|
||||
* contrib/hbziparch/hbziparc.c
|
||||
* contrib/hbziparch/hbziparc.h
|
||||
- contrib/hbziparch/zipcomp.cpp
|
||||
+ contrib/hbziparch/hbzipcom.cpp
|
||||
- contrib/hbziparch/zipnew.cpp
|
||||
+ contrib/hbziparch/hbzipnew.cpp
|
||||
- Docs integrated into source.
|
||||
- Removed .dll building batch files (highly redundant,
|
||||
non-maintained and probably non-working), so now the make
|
||||
|
||||
@@ -12,6 +12,7 @@ LIB_OBJS = \
|
||||
\
|
||||
$(OBJ_DIR)hbzipnew$(OBJEXT) \
|
||||
$(OBJ_DIR)hbzipcom$(OBJEXT) \
|
||||
\
|
||||
$(OBJ_DIR)ziparchive$(OBJEXT) \
|
||||
$(OBJ_DIR)ZipPlatform_win$(OBJEXT) \
|
||||
$(OBJ_DIR)zipstorage$(OBJEXT) \
|
||||
|
||||
@@ -73,6 +73,7 @@ static PHB_ITEM s_FileAttribs;
|
||||
PHB_ITEM hbza_ChangeDiskBlock;
|
||||
PHB_ITEM hbza_pProgressInfo = NULL;
|
||||
PHB_ITEM hbza_ZipArray;
|
||||
HB_ZIP_INTERNAL hbza_pZipI;
|
||||
|
||||
#define FA_RDONLY 1 /* R */
|
||||
#define FA_HIDDEN 2 /* H */
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbvm.h"
|
||||
#include "hbzlib.h"
|
||||
|
||||
#if defined(__GNUC__) && !defined(__MINGW32__)
|
||||
#include <sys/types.h>
|
||||
@@ -109,6 +110,7 @@ typedef LPCSTR LPCTSTR;
|
||||
extern PHB_ITEM hbza_ZipArray;
|
||||
extern PHB_ITEM hbza_ChangeDiskBlock;
|
||||
extern PHB_ITEM hbza_pProgressInfo;
|
||||
extern HB_ZIP_INTERNAL hbza_pZipI;
|
||||
|
||||
extern char * hb___CheckFile( char * szFile);
|
||||
extern PHB_ITEM hb___GetFileNamesFromZip(char *szFile,BOOL iMode);
|
||||
|
||||
@@ -58,10 +58,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern HB_ZIP_INTERNAL pZipI;
|
||||
|
||||
//bool hb_SetProgressofTdSpan( DWORD, int iSoFar, void* pData );
|
||||
|
||||
class SpanCallbackc : public CZipSpanCallback
|
||||
{
|
||||
bool Callback( int iProgress )
|
||||
@@ -79,8 +75,7 @@ class SpanActionCallbackc : public CZipActionCallback
|
||||
{
|
||||
bool Callback( int iProgress )
|
||||
{
|
||||
PHB_ITEM Disk =hb_itemPutNL(NULL, m_uTotalSoFar ), Total=hb_itemPutNL( NULL, m_uTotalToDo );
|
||||
|
||||
PHB_ITEM Disk = hb_itemPutNL(NULL, m_uTotalSoFar ), Total=hb_itemPutNL( NULL, m_uTotalToDo );
|
||||
|
||||
hb_vmEvalBlockV( hbza_pProgressInfo, 2, Disk,Total);
|
||||
|
||||
@@ -185,10 +180,10 @@ int hb_CompressFile( char *szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBl
|
||||
szZip.SetPassword( szPassWord );
|
||||
}
|
||||
|
||||
if ( pZipI.szComment != NULL )
|
||||
if ( hbza_pZipI.szComment != NULL )
|
||||
{
|
||||
szZip.SetGlobalComment( pZipI.szComment );
|
||||
hb_xfree( pZipI.szComment );
|
||||
szZip.SetGlobalComment( hbza_pZipI.szComment );
|
||||
hb_xfree( hbza_pZipI.szComment );
|
||||
}
|
||||
|
||||
if ( HB_IS_BLOCK( pProgress ) )
|
||||
@@ -309,10 +304,10 @@ int hb_CmpTdSpan( char *szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock
|
||||
szZip.SetPassword( szPassWord );
|
||||
}
|
||||
|
||||
if ( pZipI.szComment != NULL )
|
||||
if ( hbza_pZipI.szComment != NULL )
|
||||
{
|
||||
szZip.SetGlobalComment( pZipI.szComment );
|
||||
hb_xfree( pZipI.szComment );
|
||||
szZip.SetGlobalComment( hbza_pZipI.szComment );
|
||||
hb_xfree( hbza_pZipI.szComment );
|
||||
}
|
||||
|
||||
if ( HB_IS_BLOCK( pProgress ) )
|
||||
@@ -375,20 +370,6 @@ int hb_CmpTdSpan( char *szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock
|
||||
return ( int ) bReturn;
|
||||
}
|
||||
|
||||
bool hb_SetProgressofTdSpan( DWORD a, int iSoFar, void* pData ){
|
||||
|
||||
PHB_ITEM Disk=hb_itemPutNL( NULL, iSoFar ), Total= hb_itemPutNL( NULL, a ) ;
|
||||
|
||||
|
||||
HB_SYMBOL_UNUSED( pData );
|
||||
|
||||
hb_vmEvalBlockV( hbza_pProgressInfo, 2, Disk, Total);
|
||||
|
||||
hb_itemRelease( Disk );
|
||||
hb_itemRelease( Total );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int hb_CompressFileStd( char *szFile, char *szFiletoCompress, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, char *szPassWord, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
|
||||
{
|
||||
DWORD dwSize;
|
||||
@@ -426,10 +407,10 @@ int hb_CompressFileStd( char *szFile, char *szFiletoCompress, int iCompLevel, PH
|
||||
szZip.SetPassword( szPassWord );
|
||||
}
|
||||
|
||||
if ( pZipI.szComment != NULL )
|
||||
if ( hbza_pZipI.szComment != NULL )
|
||||
{
|
||||
szZip.SetGlobalComment( pZipI.szComment );
|
||||
hb_xfree( pZipI.szComment );
|
||||
szZip.SetGlobalComment( hbza_pZipI.szComment );
|
||||
hb_xfree( hbza_pZipI.szComment );
|
||||
}
|
||||
|
||||
if ( HB_IS_BLOCK( pProgress ) )
|
||||
@@ -550,10 +531,10 @@ int hb_CmpTdSpanStd( char *szFile, char * szFiletoCompress, int iCompLevel, PHB_
|
||||
szZip.SetPassword( szPassWord );
|
||||
}
|
||||
|
||||
if ( pZipI.szComment != NULL )
|
||||
if ( hbza_pZipI.szComment != NULL )
|
||||
{
|
||||
szZip.SetGlobalComment( pZipI.szComment );
|
||||
hb_xfree( pZipI.szComment );
|
||||
szZip.SetGlobalComment( hbza_pZipI.szComment );
|
||||
hb_xfree( hbza_pZipI.szComment );
|
||||
}
|
||||
|
||||
if ( HB_IS_BLOCK( pProgress ) )
|
||||
|
||||
@@ -51,19 +51,9 @@
|
||||
*/
|
||||
|
||||
#include "hbziparc.h"
|
||||
#include "hbapifs.h"
|
||||
|
||||
int hb_CheckSpanMode( char * szFile );
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
bool hb_SetCallBack( DWORD iNumber, int, void* pData );
|
||||
|
||||
extern bool hb_SetProgressofTdSpan( DWORD, int iSoFar, void* pData );
|
||||
|
||||
HB_ZIP_INTERNAL pZipI;
|
||||
|
||||
#endif
|
||||
|
||||
class SpanCallback : public CZipSpanCallback
|
||||
@@ -86,7 +76,6 @@ class SpanActionCallback : public CZipActionCallback
|
||||
{
|
||||
PHB_ITEM Disk = hb_itemPutNL( NULL , m_uTotalSoFar ), Total= hb_itemPutNL( NULL, m_uTotalToDo );
|
||||
|
||||
|
||||
hb_vmEvalBlockV( hbza_pProgressInfo, 2, Disk, Total);
|
||||
|
||||
hb_itemRelease( Disk );
|
||||
@@ -96,6 +85,152 @@ class SpanActionCallback : public CZipActionCallback
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static int hb_CheckSpanMode( char * szFile )
|
||||
{
|
||||
int iReturn = 0;
|
||||
|
||||
CZipArchive szZip;
|
||||
SpanCallback span;
|
||||
SpanActionCallback spanac;
|
||||
|
||||
szZip.SetSpanCallback( &span );
|
||||
|
||||
try
|
||||
{
|
||||
// s.r. to avoid GPF when ZIP file is read only !
|
||||
// szZip.Open( szFile, CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
}
|
||||
|
||||
catch( CZipException &e )
|
||||
{
|
||||
if ( e.m_iCause == CZipException::cdirNotFound )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 114;
|
||||
} else if ( e.m_iCause == CZipException::noCallback )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 103;
|
||||
}
|
||||
|
||||
else if ( e.m_iCause == CZipException::generic )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 100;
|
||||
}
|
||||
else if ( e.m_iCause == CZipException::badZipFile )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 101;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::badCrc )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 102;
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::aborted )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 104;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::abortedAction )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 105;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::abortedSafely )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 106;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::nonRemovable )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 107;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::tooManyVolumes )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 108;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::tooLongFileName )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 109;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::badPassword )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 110;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::dirWithSize )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 111;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::internal )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 112;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::notRemoved )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 113;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::notRenamed )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 114;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::platfNotSupp)
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 115;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ( ! iReturn )
|
||||
{
|
||||
iReturn = szZip.GetSpanMode( );
|
||||
szZip.Close( );
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
int hb_CmpPkSpan( char *szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, char *szPassWord, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
|
||||
{
|
||||
ULONG ulCount;
|
||||
@@ -143,10 +278,10 @@ int hb_CmpPkSpan( char *szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock
|
||||
szZip.SetPassword( szPassWord );
|
||||
}
|
||||
|
||||
if ( pZipI.szComment != NULL )
|
||||
if ( hbza_pZipI.szComment != NULL )
|
||||
{
|
||||
szZip.SetGlobalComment( pZipI.szComment );
|
||||
hb_xfree( pZipI.szComment );
|
||||
szZip.SetGlobalComment( hbza_pZipI.szComment );
|
||||
hb_xfree( hbza_pZipI.szComment );
|
||||
}
|
||||
|
||||
if ( HB_IS_BLOCK( pProgress ) )
|
||||
@@ -210,9 +345,9 @@ PHB_ITEM hb___GetFileNamesFromZip( char *szFile, BOOL iMode )
|
||||
CZipArchive szZip;
|
||||
SpanCallback span;
|
||||
|
||||
if ( pZipI.iWrite > 0 )
|
||||
if ( hbza_pZipI.iWrite > 0 )
|
||||
{
|
||||
szZip.SetAdvanced( pZipI.iWrite, pZipI.iExtract, pZipI.iRead );
|
||||
szZip.SetAdvanced( hbza_pZipI.iWrite, hbza_pZipI.iExtract, hbza_pZipI.iRead );
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -220,16 +355,16 @@ PHB_ITEM hb___GetFileNamesFromZip( char *szFile, BOOL iMode )
|
||||
switch( hb_CheckSpanMode( szFile ))
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
szZip.SetSpanCallback( &span );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -2:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -423,16 +558,16 @@ BOOL hb_IsPassWord( char *szFile )
|
||||
switch( hb_CheckSpanMode( szFile ) )
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
szZip.SetSpanCallback( &span );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -2:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -462,7 +597,7 @@ int hb___GetNumberofFilestoUnzip( char *szFile )
|
||||
|
||||
szZip.SetSpanCallback( &span );
|
||||
try {
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
iNumberOfFiles = szZip.GetCount( );
|
||||
szZip.Close( );
|
||||
}
|
||||
@@ -493,7 +628,7 @@ int hb___SetCallbackFunc( PHB_ITEM pFunc )
|
||||
hb_itemCopy( hbza_ChangeDiskBlock, pFunc );
|
||||
}
|
||||
|
||||
// pZipI.pItem = hbza_ChangeDiskBlock;
|
||||
// hbza_pZipI.pItem = hbza_ChangeDiskBlock;
|
||||
|
||||
return ( int ) true;
|
||||
}
|
||||
@@ -525,7 +660,7 @@ int hb_DeleteSel( char *szFile, PHB_ITEM pArray, BOOL bCase )
|
||||
switch(hb_CheckSpanMode( szFile ))
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
@@ -580,16 +715,16 @@ int hb_UnzipSel( char *szFile, PHB_ITEM pBlock, BOOL lWithPath, char *szPassWord
|
||||
switch( hb_CheckSpanMode( szFile ) )
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
szZip.SetSpanCallback( &span );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -2:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -717,21 +852,21 @@ int hb_TestForPKS( char *szFile )
|
||||
|
||||
void hb_SetZipBuff( int a, int b, int c )
|
||||
{
|
||||
pZipI.iWrite = a > 65535 ? a : 65535;
|
||||
pZipI.iExtract = b > 16384 ? b : 16384;
|
||||
pZipI.iRead = c > 32768 ? c : 32768;
|
||||
hbza_pZipI.iWrite = a > 65535 ? a : 65535;
|
||||
hbza_pZipI.iExtract = b > 16384 ? b : 16384;
|
||||
hbza_pZipI.iRead = c > 32768 ? c : 32768;
|
||||
}
|
||||
|
||||
void hb_SetZipComment( char *szComment )
|
||||
{
|
||||
int iLen = strlen( ( const char * ) szComment ) + 1;
|
||||
pZipI.szComment = ( char* ) hb_xgrab( iLen );
|
||||
strcpy( pZipI.szComment, szComment );
|
||||
hbza_pZipI.szComment = ( char* ) hb_xgrab( iLen );
|
||||
strcpy( hbza_pZipI.szComment, szComment );
|
||||
}
|
||||
|
||||
void hb_SetZipReadOnly(int iRead )
|
||||
{
|
||||
pZipI.iReadOnly = iRead ;
|
||||
hbza_pZipI.iReadOnly = iRead ;
|
||||
}
|
||||
|
||||
const char * hb_GetZipComment( char *szFile )
|
||||
@@ -750,16 +885,16 @@ const char * hb_GetZipComment( char *szFile )
|
||||
switch( hb_CheckSpanMode( szFile ) )
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
szZip.SetSpanCallback( &span );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -2:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -806,16 +941,16 @@ int hb_UnzipSelIndex( char *szFile, PHB_ITEM pBlock, BOOL lWithPath, char *szPas
|
||||
switch( hb_CheckSpanMode( szFile ) )
|
||||
{
|
||||
case 0:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
szZip.SetSpanCallback( &span );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -2:
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
szZip.Open( szFile, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 1 );
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -898,7 +1033,7 @@ BOOL hb_TransferFilesFromzip( char *szSource, char *szDest, PHB_ITEM pArray )
|
||||
switch(hb_CheckSpanMode( szSource ))
|
||||
{
|
||||
case 0:
|
||||
szZSource.Open( szSource, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZSource.Open( szSource, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
@@ -915,7 +1050,7 @@ BOOL hb_TransferFilesFromzip( char *szSource, char *szDest, PHB_ITEM pArray )
|
||||
switch(hb_CheckSpanMode( szDest ))
|
||||
{
|
||||
case 0:
|
||||
szZDest.Open( szDest, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
szZDest.Open( szDest, hbza_pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
break;
|
||||
|
||||
case -1:
|
||||
@@ -999,7 +1134,9 @@ int hb_UnzipAll(char *szFile,PHB_ITEM pBlock, BOOL bWithPath,char *szPassWord,ch
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CZipException &e) {
|
||||
catch (CZipException &e)
|
||||
{
|
||||
HB_SYMBOL_UNUSED( e );
|
||||
// iCause=e.m_iCause ;
|
||||
}
|
||||
|
||||
@@ -1054,23 +1191,21 @@ int hb_UnzipAll(char *szFile,PHB_ITEM pBlock, BOOL bWithPath,char *szPassWord,ch
|
||||
|
||||
|
||||
try {
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile( ( WORD )uiCount, ( LPCTSTR )szPath, bWithPath, NULL, 65536 );
|
||||
}
|
||||
else
|
||||
{
|
||||
szZip.SetPassword(szPassWord);
|
||||
|
||||
szZip.ExtractFile( ( WORD )uiCount, ( LPCTSTR )szPath, bWithPath, NULL, 65536 );
|
||||
}
|
||||
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile( ( WORD )uiCount, ( LPCTSTR )szPath, bWithPath ? true : false, NULL, 65536 );
|
||||
}
|
||||
else
|
||||
{
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile( ( WORD )uiCount, ( LPCTSTR )szPath, bWithPath ? true : false, NULL, 65536 );
|
||||
}
|
||||
}
|
||||
catch ( CZipException& e )
|
||||
{
|
||||
szZip.CloseFile( NULL, true);
|
||||
HB_SYMBOL_UNUSED( e );
|
||||
// iCause=e.m_iCause ;
|
||||
}
|
||||
if(bChange)
|
||||
@@ -1098,148 +1233,3 @@ return iReturn;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int hb_CheckSpanMode( char * szFile )
|
||||
{
|
||||
int iReturn = 0;
|
||||
|
||||
CZipArchive szZip;
|
||||
SpanCallback span;
|
||||
SpanActionCallback spanac;
|
||||
|
||||
szZip.SetSpanCallback( &span );
|
||||
|
||||
try
|
||||
{
|
||||
// s.r. to avoid GPF when ZIP file is read only !
|
||||
// szZip.Open( szFile, CZipArchive::zipOpen, 0 );
|
||||
szZip.Open( szFile, pZipI.iReadOnly ? CZipArchive::zipOpenReadOnly : CZipArchive::zipOpen, 0 );
|
||||
}
|
||||
|
||||
catch( CZipException &e )
|
||||
{
|
||||
if ( e.m_iCause == CZipException::cdirNotFound )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 114;
|
||||
} else if ( e.m_iCause == CZipException::noCallback )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 103;
|
||||
}
|
||||
|
||||
else if ( e.m_iCause == CZipException::generic )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 100;
|
||||
}
|
||||
else if ( e.m_iCause == CZipException::badZipFile )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 101;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::badCrc )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 102;
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::aborted )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 104;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::abortedAction )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 105;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::abortedSafely )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 106;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::nonRemovable )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 107;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::tooManyVolumes )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 108;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::tooLongFileName )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 109;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::badPassword )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 110;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::dirWithSize )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 111;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::internal )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 112;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::notRemoved )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 113;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::notRenamed )
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 114;
|
||||
}
|
||||
|
||||
|
||||
else if ( e.m_iCause == CZipException::platfNotSupp)
|
||||
{
|
||||
szZip.Close( true );
|
||||
iReturn = 115;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ( ! iReturn )
|
||||
{
|
||||
iReturn = szZip.GetSpanMode( );
|
||||
szZip.Close( );
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||
CAN CHANGE IN FUTURE VERSION !!
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip */
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#include "hbzlib.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment, uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
@@ -1,151 +0,0 @@
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 0.15 alpha, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||
CAN CHANGE IN FUTURE VERSION !!
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/zip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
|
||||
#include "hbzlib.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagzipFile__ { int unused; } zipFile__;
|
||||
typedef zipFile__ *zipFile;
|
||||
#else
|
||||
typedef voidp zipFile;
|
||||
#endif
|
||||
|
||||
#define ZIP_OK (0)
|
||||
#define ZIP_ERRNO (Z_ERRNO)
|
||||
#define ZIP_PARAMERROR (-102)
|
||||
#define ZIP_INTERNALERROR (-104)
|
||||
|
||||
/* tm_zip contain date/time info */
|
||||
typedef struct tm_zip_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_zip;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
tm_zip tmz_date; /* date in understandable format */
|
||||
uLong dosDate; /* if dos_date == 0, tmu_date is used */
|
||||
/* uLong flag; */ /* general purpose bit flag 2 bytes */
|
||||
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
} zip_fileinfo;
|
||||
|
||||
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on
|
||||
an Unix computer "zlib/zlib111.zip".
|
||||
if the file pathname exist and append=1, the zip will be created at the end
|
||||
of the file. (useful if the file contain a self extractor code)
|
||||
If the zipfile cannot be opened, the return value is NULL.
|
||||
Else, the return value is a zipFile Handle, usable with other function
|
||||
of this zip package.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
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));
|
||||
/*
|
||||
Open a file in the ZIP for writing.
|
||||
filename : the filename in zip (if NULL, '-' without quote will be used
|
||||
*zipfi contain supplemental information
|
||||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
|
||||
contains the extrafield data the the local header
|
||||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
|
||||
contains the extrafield data the the local header
|
||||
if comment != NULL, comment contain the comment string
|
||||
method contain the compression method (0 for store, Z_DEFLATED for deflate)
|
||||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipClose OF((zipFile file,
|
||||
const char* global_comment));
|
||||
/*
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
||||
Reference in New Issue
Block a user