See changelog 2001-10-08 21:30 GMT -3
This commit is contained in:
@@ -108,14 +108,20 @@ extern int hb_CmpTdSpanStd(char *szFile,char * szFiletoCompress,int iCompLe
|
||||
extern int hb_UnzipAll(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,PHB_ITEM pDiskBlock,PHB_ITEM pProgress);
|
||||
extern int hb_UnzipOne(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,char *szFiletoExtract,PHB_ITEM pProgress);
|
||||
extern int hb_UnzipSel(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,PHB_ITEM pArray,PHB_ITEM pProgress);
|
||||
|
||||
extern int hb_UnzipOneIndex(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,int uiCount,PHB_ITEM pProgress);
|
||||
extern int hb_UnzipSelIndex(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,PHB_ITEM pSelArray,PHB_ITEM pProgress);
|
||||
extern int hb_DeleteOne(char *szFile,char *szFiletoDelete);
|
||||
extern int hb_DeleteSel(char *szFile,PHB_ITEM pArray,BOOL bCase);
|
||||
extern int hb_DeleteOneIndex(char *szFile,int uiCount);
|
||||
extern int hb_TestForPKS(char *szFile);
|
||||
extern void hb_SetZipBuff(int a,int b,int c);
|
||||
extern void hb_SetZipComment(char *szComment);
|
||||
extern char *hb_GetZipComment(char *szFile);
|
||||
extern BOOL hb_IsPassWord(char *szName);
|
||||
extern unsigned long GetCurrentFileSize( LPCTSTR szFile);
|
||||
extern BOOL hb_SaveZipFileFromMemory(char *szFile);
|
||||
extern BOOL hb_CreateZipInMemory(char *szFileToCompress,char *szFile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -80,15 +80,13 @@ HB_FUNC(HB_GETFILESINZIP)
|
||||
hb_itemRelease(pArray);
|
||||
}
|
||||
}
|
||||
/*
|
||||
HB_FUNC(HB_ZIPGETPASSWORD)
|
||||
|
||||
HB_FUNC(HB_ZIPWITHPASSWORD)
|
||||
{
|
||||
char *szName=hb_parc(1);
|
||||
char *szPassWord;
|
||||
szPassWord=hb_getPassWord(szName);
|
||||
hb_retc(szPassWord);
|
||||
|
||||
hb_retl(hb_IsPassWord(hb_parc(1)));
|
||||
}
|
||||
*/
|
||||
|
||||
HB_FUNC(HB_GETUNZIPFILE)
|
||||
{
|
||||
if( ISCHAR(1) ){
|
||||
@@ -166,7 +164,13 @@ HB_FUNC(HB_ZIPDELETEFILES)
|
||||
char szFile[_POSIX_PATH_MAX];
|
||||
strcpy(szFile,hb_parc(1));
|
||||
hb_retl(hb_DeleteSel(hb___CheckFile(szFile),hb_param(2,HB_IT_ARRAY),ISLOG(3) ? hb_parl(3) : 0));
|
||||
}
|
||||
}
|
||||
if (ISCHAR(1)&&ISNUM(2)) {
|
||||
char szFile[_POSIX_PATH_MAX];
|
||||
strcpy(szFile,hb_parc(1));
|
||||
hb_retl(hb_DeleteOneIndex(hb___CheckFile(szFile),hb_parni(2)));
|
||||
}
|
||||
|
||||
}
|
||||
HB_FUNC(HB_ZIPTESTPK)
|
||||
{
|
||||
@@ -187,3 +191,29 @@ HB_FUNC(HB_GETZIPCOMMENT)
|
||||
{
|
||||
hb_retc(hb_GetZipComment(hb_parc(1)));
|
||||
}
|
||||
HB_FUNC(HB_UNZIPFILEINDEX)
|
||||
|
||||
{
|
||||
if( ISCHAR(1) && ISNUM(6) ){
|
||||
char szFile[_POSIX_PATH_MAX];
|
||||
strcpy(szFile,hb_parc(1));
|
||||
|
||||
hb_retl(hb_UnzipOneIndex(hb___CheckFile(szFile),hb_param( 2, HB_IT_BLOCK),ISLOG(3) ? hb_parl(3) : 0 ,hb_parc(4),hb_parc(5),hb_parni(6),hb_itemParam(7)));
|
||||
}
|
||||
if( ISCHAR(1) && ISARRAY(6) ){
|
||||
char szFile[_POSIX_PATH_MAX];
|
||||
strcpy(szFile,hb_parc(1));
|
||||
|
||||
hb_retl(hb_UnzipSelIndex(hb___CheckFile(szFile),hb_param( 2, HB_IT_BLOCK),ISLOG(3) ? hb_parl(3) : 0 ,hb_parc(4),hb_parc(5),hb_param(6,HB_IT_ARRAY),hb_itemParam(7)));
|
||||
}
|
||||
|
||||
}
|
||||
HB_FUNC(HB_ZIPINMEMORY)
|
||||
{
|
||||
hb_retl(hb_CreateZipInMemory(hb_parc(1),hb_parc(2)));
|
||||
}
|
||||
/*HB_FUNC(HB_SAVEZIPFROMMEMORY)
|
||||
{
|
||||
hb_retl(hb_SaveZipFileFromMemory());
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
@@ -56,7 +57,7 @@ extern PHB_ITEM pArray;
|
||||
PHB_ITEM pDiskStatus=NULL;
|
||||
PHB_ITEM pProgressInfo=NULL;
|
||||
int iTotal=0;
|
||||
|
||||
CZipMemFile mf;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -98,8 +99,8 @@ int hb_CompressFile(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBloc
|
||||
bReturn=false;
|
||||
}
|
||||
catch(...){}
|
||||
if (pProgress != NULL)
|
||||
pProgressInfo=pProgress;
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
for (uiCount=1;(uiCount<= hb_arrayLen(pArray)) ;uiCount++)
|
||||
{
|
||||
const char *szDummy = (char *)hb_arrayGetCPtr(pArray,uiCount) ;
|
||||
@@ -112,7 +113,7 @@ int hb_CompressFile(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBloc
|
||||
}
|
||||
if (uiPos== hb_arrayLen(pArray))
|
||||
iTotal+=dwSize;
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
#if defined(HB_OS_WIN_32) || defined(__MINGW32__)
|
||||
if (bDrive)
|
||||
@@ -212,7 +213,7 @@ int hb_CompressFile(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBloc
|
||||
bReturn=false;
|
||||
}
|
||||
catch(...){}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
for (uiCount=1;(uiCount<= hb_arrayLen(pArray)) ;uiCount++)
|
||||
@@ -227,7 +228,7 @@ int hb_CompressFile(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBloc
|
||||
if (uiPos== hb_arrayLen(pArray))
|
||||
iTotal+=dwSize;
|
||||
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
#if defined(HB_OS_WIN_32) || defined(__MINGW32__)
|
||||
@@ -343,7 +344,7 @@ int hb_CompressFileStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_
|
||||
iCause=e->m_iCause ;
|
||||
bReturn=false;
|
||||
}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
@@ -351,7 +352,7 @@ int hb_CompressFileStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_
|
||||
if (szPassWord != NULL){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
#if defined(HB_OS_WIN_32) || defined(__MINGW32__)
|
||||
@@ -439,7 +440,7 @@ int hb_CompressFileStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_
|
||||
iCause=e.m_iCause ;
|
||||
}
|
||||
catch(...){}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
@@ -447,7 +448,7 @@ int hb_CompressFileStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
dwSize=GetCurrentFileSize(szFiletoCompress);
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
#if defined(HB_OS_WIN_32) || defined(__MINGW32__)
|
||||
@@ -491,6 +492,48 @@ int hb_CompressFileStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_
|
||||
pDiskStatus=NULL ;
|
||||
return true; /* to avoid warning */
|
||||
}
|
||||
BOOL hb_CreateZipInMemory(char *szFileToCompress,char *szFile)
|
||||
{
|
||||
BOOL bReturn=FALSE;
|
||||
CZipArchive zip;
|
||||
CZipMemFile mf1;
|
||||
CZipFile f;
|
||||
zip.Open(mf1, CZipArchive::zipCreate);
|
||||
zip.AddNewFile(szFileToCompress, 8, true,NULL,NULL,65536);
|
||||
zip.Close();
|
||||
if (szFile !=NULL)
|
||||
{
|
||||
if (f.Open(szFile, CZipFile::modeWrite|CZipFile::modeCreate, false))
|
||||
{
|
||||
int iLen = mf1.GetLength();
|
||||
BYTE* b = mf1.Detach();
|
||||
f.Write(b, iLen);
|
||||
f.Close();
|
||||
// must free detached memory
|
||||
free(b);
|
||||
bReturn=TRUE;
|
||||
}
|
||||
}
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
BOOL hb_SaveZipFileFromMemory(char *szFile)
|
||||
{
|
||||
CZipArchive zip;
|
||||
CZipFile f;
|
||||
BOOL bReturn=FALSE;
|
||||
if (f.Open(szFile, CZipFile::modeWrite|CZipFile::modeCreate, false))
|
||||
{
|
||||
int iLen = mf.GetLength();
|
||||
BYTE* b = mf.Detach();
|
||||
f.Write(b, iLen);
|
||||
f.Close();
|
||||
// must free detached memory
|
||||
free(b);
|
||||
bReturn=TRUE;
|
||||
}
|
||||
return bReturn;
|
||||
}
|
||||
#if defined(HB_OS_WIN_32) || defined(__MINGW32__)
|
||||
DWORD GetCurrentFileSize( LPCTSTR szFile)
|
||||
{
|
||||
|
||||
@@ -102,7 +102,7 @@ int hb_CmpPkSpan(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBlock,BO
|
||||
bReturn=false;
|
||||
}
|
||||
catch(...){}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
for (uiCount=1;(uiCount<= hb_arrayLen(pArray)) ;uiCount++)
|
||||
@@ -117,7 +117,7 @@ int hb_CmpPkSpan(char *szFile,PHB_ITEM pArray,int iCompLevel,PHB_ITEM pBlock,BO
|
||||
}
|
||||
if (uiPos== hb_arrayLen(pArray))
|
||||
iTotal+=dwSize;
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
#if defined(__WIN32__) || defined(__MINGW32__)
|
||||
@@ -247,12 +247,12 @@ if (iReturn) {
|
||||
pItem=hb_itemPutC(NULL,(char *)szFileNameInZip);
|
||||
hb_itemArrayPut(pTempArray,filePos,pItem);
|
||||
hb_itemRelease(pItem);
|
||||
/*
|
||||
#if defined(__WIN32__)
|
||||
szAttr[0] = uAttr & FILE_ATTRIBUTE_READONLY ? _T('r') : _T('-');
|
||||
szAttr[1] = uAttr & FILE_ATTRIBUTE_HIDDEN ? _T('h') : _T('-');
|
||||
szAttr[2] = uAttr & FILE_ATTRIBUTE_SYSTEM ? _T('s') : _T('w');
|
||||
szAttr[3] = (uAttr & FILE_ATTRIBUTE_DIRECTORY) ? _T('D') : uAttr & FILE_ATTRIBUTE_ARCHIVE ? _T('a'): _T('-');
|
||||
*/
|
||||
#endif
|
||||
szAttr[4] = fh.IsEncrypted() ? _T('*') : _T(' ');
|
||||
|
||||
if (fh.m_uUncomprSize>0) {
|
||||
@@ -389,23 +389,46 @@ if (iReturn) {
|
||||
strcpy(szTempTime, asctime(&t));
|
||||
|
||||
}
|
||||
char *hb_getPassWord(char *szName)
|
||||
BOOL hb_IsPassWord(char *szFile)
|
||||
{
|
||||
const char * szTempPass;
|
||||
bool bReturn=false;
|
||||
CZipArchive szZip;
|
||||
CZipString szPassWord;
|
||||
int iNumbersOfFiles;
|
||||
int iMode=0;
|
||||
iMode=hb_CheckSpamMode(szFile);
|
||||
int iCause=0;
|
||||
bool iReturn=true;
|
||||
CZipFileHeader fh;
|
||||
szZip.SetSpanCallback(hb_SetCallBack,NULL);
|
||||
szZip.Open(szName,CZipArchive::zipOpen,0);
|
||||
try {
|
||||
if(iMode==0) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode ==-1) {
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode==-2) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,1);
|
||||
}
|
||||
else {
|
||||
iReturn =false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CZipException& e) {
|
||||
iCause=e.m_iCause ;
|
||||
}
|
||||
|
||||
iNumbersOfFiles=szZip.GetNoEntries();
|
||||
szZip.GetFileInfo(fh, (WORD)1);
|
||||
szZip.GetFileInfo(fh, (WORD)0);
|
||||
if (fh.IsEncrypted()){
|
||||
szPassWord= szZip.GetPassword();
|
||||
szTempPass=(const char *) szPassWord;
|
||||
bReturn=true;
|
||||
}
|
||||
szZip.Close();
|
||||
return (char*)szTempPass;
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
|
||||
@@ -460,7 +483,7 @@ int hb_CmpPkSpanStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_ITEM
|
||||
bReturn=false;
|
||||
}
|
||||
catch(...){}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
@@ -468,7 +491,7 @@ int hb_CmpPkSpanStd(char *szFile,char *szFiletoCompress,int iCompLevel,PHB_ITEM
|
||||
if (szPassWord != NULL){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
#if defined(__WIN32__) || defined(__MINGW32__)
|
||||
@@ -555,6 +578,7 @@ uLong uiCount=0;
|
||||
int iCause=0;
|
||||
int iMode=true;
|
||||
CZipArchive szZip;
|
||||
iTotal=0;
|
||||
if (pDiskBlock){
|
||||
pChangeDiskBlock=pDiskBlock;
|
||||
}
|
||||
@@ -562,26 +586,26 @@ if (pDiskBlock){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
iMode=hb_CheckSpamMode(szFile);
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
if(iMode==0) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (iMode ==-1) {
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (iMode==-2) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
iReturn =false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CZipException& e) {
|
||||
@@ -598,9 +622,9 @@ iMode=hb_CheckSpamMode(szFile);
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
szTempString =(LPCTSTR)fh.GetFileName();
|
||||
szFileNameInZip=(const char *)szTempString;
|
||||
|
||||
iTotal=fh.m_uUncomprSize ;
|
||||
try {
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
@@ -641,6 +665,7 @@ bool iReturn=true;
|
||||
int uiCount=0;
|
||||
int iCause=0;
|
||||
int iMode=0;
|
||||
iTotal=0;
|
||||
CZipArchive szZip;
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
iMode=hb_CheckSpamMode(szFile) ;
|
||||
@@ -683,7 +708,7 @@ iMode=hb_CheckSpamMode(szFile) ;
|
||||
/* if (iCause != 0){
|
||||
szZip.Close();
|
||||
}*/
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
uiCount = szZip.FindFile((LPCTSTR)szFiletoExtract,false);
|
||||
@@ -700,7 +725,7 @@ iMode=hb_CheckSpamMode(szFile) ;
|
||||
szFileNameInZip=(const char *)szTempString;
|
||||
|
||||
try {
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
@@ -758,7 +783,7 @@ iMode=hb_CheckSpamMode(szFile);
|
||||
if (uiCount ==-1){
|
||||
uiCount = szZip.FindFile((LPCTSTR)szFiletoDelete,true);
|
||||
}
|
||||
if (uiCount >0){
|
||||
if (uiCount >=0){
|
||||
CZipFileHeader fh;
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
if (szZip.DeleteFile((WORD)uiCount))
|
||||
@@ -823,11 +848,12 @@ int uiCount=0;
|
||||
int iCause=0;
|
||||
CZipArchive szZip;
|
||||
int iMode=0;
|
||||
iTotal=0;
|
||||
iMode=hb_CheckSpamMode(szFile);
|
||||
if (szPassWord != NULL){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
if (pProgress != NULL)
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
@@ -865,9 +891,9 @@ iMode=hb_CheckSpamMode(szFile);
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
szTempString =(LPCTSTR)fh.GetFileName();
|
||||
szFileNameInZip=(const char *)szTempString;
|
||||
|
||||
iTotal=fh.m_uUncomprSize ;
|
||||
try {
|
||||
if (pProgress == NULL)
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
@@ -959,6 +985,216 @@ return (char*)szReturn;
|
||||
|
||||
}
|
||||
|
||||
int hb_UnzipOneIndex(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,int uiCount,PHB_ITEM pProgress)
|
||||
{
|
||||
bool iReturn=true;
|
||||
int iCause=0;
|
||||
int iMode=0;
|
||||
iTotal=0;
|
||||
uiCount--;
|
||||
CZipArchive szZip;
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
iMode=hb_CheckSpamMode(szFile) ;
|
||||
if (szPassWord != NULL){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
/*
|
||||
try {
|
||||
if (hb_CheckSpamMode(szFile) !=-2) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else{
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
try {
|
||||
if(iMode==0) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode ==-1) {
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode==-2) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,1);
|
||||
}
|
||||
else {
|
||||
iReturn =false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (CZipException& e) {
|
||||
iCause=e.m_iCause ;
|
||||
}
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
if (uiCount >=0){
|
||||
CZipFileHeader fh;
|
||||
const char * szFileNameInZip;
|
||||
CZipString szTempString;
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
szTempString =(LPCTSTR)fh.GetFileName();
|
||||
iTotal=fh.m_uUncomprSize;
|
||||
szFileNameInZip=(const char *)szTempString;
|
||||
|
||||
try {
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile((WORD)uiCount,(LPCTSTR)szPath,bWithPath,NULL,NULL,NULL);
|
||||
}
|
||||
else {
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile((WORD)uiCount,(LPCTSTR)szPath,bWithPath,NULL, hb_SetProgressofUnc,(void*)&pProgress);
|
||||
|
||||
}
|
||||
}
|
||||
catch (CZipException& e)
|
||||
{
|
||||
iCause=e.m_iCause ;
|
||||
}
|
||||
if(pBlock !=NULL){
|
||||
|
||||
PHB_ITEM pFileName=hb_itemPutC(NULL,(char *)szFileNameInZip);
|
||||
hb_vmEvalBlockV( pBlock, 1, pFileName );
|
||||
hb_itemRelease(pFileName);
|
||||
}
|
||||
|
||||
}
|
||||
szZip.Close();
|
||||
if (pChangeDiskBlock){
|
||||
hb_itemRelease(pChangeDiskBlock);
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
int hb_UnzipSelIndex(char *szFile,PHB_ITEM pBlock,BOOL bWithPath,char *szPassWord,char *szPath,PHB_ITEM pSelArray,PHB_ITEM pProgress)
|
||||
{
|
||||
bool iReturn=true;
|
||||
int uiCount=0;
|
||||
int iCause=0;
|
||||
CZipArchive szZip;
|
||||
int iMode=0;
|
||||
iTotal=0;
|
||||
iMode=hb_CheckSpamMode(szFile);
|
||||
if (szPassWord != NULL){
|
||||
szZip.SetPassword(szPassWord);
|
||||
}
|
||||
if (HB_IS_BLOCK(pProgress))
|
||||
pProgressInfo=pProgress;
|
||||
|
||||
try {
|
||||
if(iMode==0) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode ==-1) {
|
||||
szZip.SetSpanCallback(hb_SetCallBack,(void*) &pChangeDiskBlock);
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode==-2) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,1);
|
||||
}
|
||||
else {
|
||||
iReturn =false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CZipException* e) {
|
||||
iCause=e->m_iCause ;
|
||||
}
|
||||
if (iReturn) {
|
||||
for (iCause=0;(iCause<= hb_arrayLen(pSelArray)) ;iCause++){
|
||||
uiCount= hb_arrayGetNI(pSelArray,iCause)-1;
|
||||
if (uiCount >=0){
|
||||
CZipFileHeader fh;
|
||||
const char * szFileNameInZip;
|
||||
CZipString szTempString;
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
szTempString =(LPCTSTR)fh.GetFileName();
|
||||
szFileNameInZip=(const char *)szTempString;
|
||||
iTotal=fh.m_uUncomprSize ;
|
||||
try {
|
||||
if (!HB_IS_BLOCK(pProgress))
|
||||
{
|
||||
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile((WORD)uiCount,(LPCTSTR)szPath,bWithPath,NULL,NULL,NULL);
|
||||
}
|
||||
else {
|
||||
szZip.SetPassword(szPassWord);
|
||||
szZip.ExtractFile((WORD)uiCount,(LPCTSTR)szPath,bWithPath,NULL,hb_SetProgressofUnc,(void*)&pProgress);
|
||||
}
|
||||
}
|
||||
catch (CZipException* e)
|
||||
{
|
||||
iCause=e->m_iCause ;
|
||||
}
|
||||
if(pBlock !=NULL){
|
||||
|
||||
PHB_ITEM pFileName=hb_itemPutC(NULL,(char *)szFileNameInZip);
|
||||
hb_vmEvalBlockV( pBlock, 1, pFileName );
|
||||
hb_itemRelease(pFileName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pChangeDiskBlock){
|
||||
hb_itemRelease(pChangeDiskBlock);
|
||||
}
|
||||
szZip.Close();
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
int hb_DeleteOneIndex(char *szFile,int uiCount)
|
||||
{
|
||||
bool iReturn;
|
||||
|
||||
int iCause=0;
|
||||
uiCount--;
|
||||
CZipArchive szZip;
|
||||
int iMode=0;
|
||||
iMode=hb_CheckSpamMode(szFile);
|
||||
try {
|
||||
if(iMode==0) {
|
||||
szZip.Open(szFile,CZipArchive::zipOpen,0);
|
||||
}
|
||||
else {
|
||||
if (iMode ==-1 ||iMode == -2) {
|
||||
iReturn =false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (CZipException e) {
|
||||
iCause=e.m_iCause ;
|
||||
}
|
||||
if (uiCount >=0){
|
||||
CZipFileHeader fh;
|
||||
szZip.GetFileInfo(fh, (WORD)uiCount);
|
||||
if (szZip.DeleteFile((WORD)uiCount))
|
||||
iReturn = true;
|
||||
else
|
||||
iReturn = false;
|
||||
}
|
||||
szZip.Close();
|
||||
if (pChangeDiskBlock){
|
||||
hb_itemRelease(pChangeDiskBlock);
|
||||
}
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#if defined(HB_OS_WIN_32) && !defined(__RSXNT__)
|
||||
#if defined(HB_OS_WIN_32) && !defined(__RSXNT__) && !defined(__CYGWIN__)
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <winspool.h>
|
||||
|
||||
Reference in New Issue
Block a user