Vytas wrote:Thanks Richard,
I downloaded the contribution libs from Xharbour and put the hbzip.lib into directory d:\harbour\lib. Modified my rmk file it include hbzip.lib as follows.
HBDIR=d:\harbour
BCDIR=d:\Borland\bcc55
FWDIR=d:\fwh
snip ...
echo $(HBDIR)\lib\codepage.lib + >> b32.bc
echo $(HBDIR)\lib\hbzip.lib + >> b32.bc
snip ...
In testing I added the following line to my function
LOCAL oZipFile := ZipNew()
The compile seems to run fine, however on linking I get the following error.
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_HB_FUN_ZIPNEW' referenced from T:\T1\PRG\OBJ\CTI.OBJ
Any idea of what I am missing? Do I need some additional libs or is something else missing?
Thanks,
Vytas
Vytas,
This is a snapshot of my backup/restore program using hbzzip/unzip wuith meter progress, Comments ae in french, if you need help, let me know
Richard
DEFINE DIALOG oDlg NAME "ZIP"
REDEFINE SAY oSource PROMPT cpath ID 101 OF oDlg
REDEFINE SAY oTarget PROMPT cDEST ID 102 OF oDlg
REDEFINE GET OFILE VAR DFILE ID 103 OF ODLG READONLY UPDATE COLOR CLR_BLUE
REDEFINE METER oMEtEr VAR nPerc1 ID 150 OF oDlg TOTAL 100
REDEFINE BUTTON OBTNOK ID 01 OF oDlg ;
ACTION (OBTNOK:DISABLE(),OBTNCAN:DISABLE(),ZIPME(OMETER,cPATH,CDEST,@LSAVE,SOUSREP,ODLG,@DFILE,OFILE))
REDEFINE BUTTON OBTNCAN ID 02 OF oDlg ;
ACTION LSAVE := .F., oDlg:end()
ACTIVATE DIALOG oDlg CENTERED
IF LSAVE
ECRSTAT("S")
ENDIF
RETURN NIL
STATIC FUNCTION ZIPME(OMETER,cPATH,CDEST,LSAVE,SOUSREP,ODLG,DLGFILE,OBJFILE)
LOCAL aFiles := {}, ;
lZipWithPath := .t., ;
lZipDone := .T.
LOCAL aDir := DIRECTORY(CURDRIVE() + ":" + CURDIR() + "\*.*","D")
LOCAL NCTR := 0
LOCAL NLEN := 0, ;
CZIP
MSGINFO("Veuillez insérer votre disque dans le lecteur")
cZip := CDEST + "DATA.ZIP"
IF FILE("DATA.ZIP")
ERASE "DATA.ZIP"
ENDIF
IF FILE(CZIP)
ERASE (CZIP)
ENDIF
FillFiles( @aFiles, aDir, cPath,SOUSREP )
nLEN := len(afiles)
lZipDone := HB_ZIPFILE( cZip , aFiles , 9, {|cFile,nPos| UPDMETER(CFILE,OMETER,NPOS,@nctr,NLEN,ODLG,@DLGFILE,OBJFILE)}, ;
.T.,, lZipWithPath, .F. )
IF ! lZipdone
ALERT("Erreur création fichier Zip " )
RETURN NIL
ENDIF
CDEST := CURDRIVE() + ":" + CURDIR() + "\DATA.ZIP"
erase (cdEST)
COPY FILE (CZIP) TO (CDEST)
tone( 500,1 )
tone( 600,1 )
tone( 700,1 )
MSGINFO("Sauvegarde terminée")
LSAVE := .T.
ODLG:END()
RETURN NIL
STATIC Function FillFiles( aFiles, cDir, cPath,SOUSREP )
LOCAL aSubDir,cItem,LEXT
FOR EACH cItem IN cDir
IF cItem[5] <> "D"
LEXT := ALLTRIM(CITEM[1])
LEXT := SUBS(LEXT,LEN(LEXT) -2 ,3)
IF UPPER(CITEM[1]) # "DATA.ZIP" .AND. UPPER(CITEM[1]) # "PRO99.EXE" ;
.AND. UPPER(CITEM[1]) # "CBATIWIN.EXE" .AND. UPPER(CITEM[1]) # "XHBZIPDLL.DLL" ;
.AND. UPPER(LEXT) # "DLL" .AND. UPPER(LEXT) # "EXE" .AND. UPPER(LEXT) # "ZIP"
SETFILEATTRIBUTES(cPath+cItem[1], FILE_ATTRIBUTE_ARCHIVE )
AADD( aFiles, cPath+cItem[1] )
ENDIF
ELSEIF cItem[1] <> "." .AND. cItem[1] <> ".."
IF SOUSREP
aSubDir := DIRECTORY( cPath+cItem[1]+"\*.*", "D" )
aFiles := FillFiles( aFiles ,aSubdir , cPath+cItem[1]+"",SOUSREP )
ENDIF
ENDIF
NEXT
RETURN aFiles
DLL32 FUNCTION SETFILEATTRIBUTES(cFileName AS LPSTR, nFileAttributes AS DWORD ) ;
AS BOOL PASCAL FROM "SetFileAttributesA" LIB "Kernel32.dll"
STATIC FUNCTION UPDMETER(CFILE,OMETER,NPOS,nctr,NLEN,ODLG,DLGFILE,OBJFILE)
NCTR++
DLGFILE := CFILE + SPACE(30)
OBJFILE:REFRESH()
ometer:set(nCTR * 100 / NLEN)
sysrefresh()
return nil
//----------------------------------------------------------------------------//
FUNCTION REST(fico)
LOCAL SOUSREP := .F., ;
cPath := CURDRIVE()+":"+CURDIR()+"", ;
NPERC1 := 0, ;
LSAVE := .F., ;
DFILE := SPACE(80), ;
ODLG,OMETER,OFILE,CZIP,Osource,Otarget,OBTNOK,OBTNCAN
LOCAL cIniFile := GetWinDir()+"\CBATI.CFG"
IF ! FILE("DEVZIP.DBF")
IF ! CUTILZIP()
RETURN NIL
ENDIF
ENDIF
CZIP := GetPvProfString("USER","SAUVEGARDE",,CINIFile )
IF CZIP = " " .OR. CZIP = NIL .OR. CZIP < "A" .OR. CZIP > "Z"
IF FILE("DEVPILOT.DBF")
IF ! NETOPEN("DEVPILOT")
RETURN NIL
ENDIF
CZIP := SUBS(DEVPILOT->PARAM2,41,1)
SOUSREP := SUBS(DEVPILOT->PARAM2,58,1)
WRITEPPROSTRING("USER" ,"SAUVEGARDE" ,CZIP , cIniFile )
CZIP := GetPvProfString("USER","SAUVEGARDE",,CINIFile )
WRITEPPROSTRING("USER" ,"SAUVESDIR" ,SOUSREP , cIniFile )
SOUSREP := .F.
ENDIF
ENDIF
DBCLOSEALL()
MSGINFO("Attention, Vous demandez d'écraser vos fichiers actuels" + ;
CRLF + "Par votre sauvegarde, veuillez reconfirmer")
IF ! MSGYESNO("Voulez-vous vraiment restituer sur disque votre sauvegarde ?", ;
"Veuillez reconfirmer")
RETURN NIL
ENDIF
IF CZIP = "A"
MSGSTOP("Sauvegarde sur disquettes non supportée")
RETURN NIL
ENDIF
IF CZIP == " "
MSGSTOP("Lecteur non identifié, restitution impossible")
RETURN NIL
ENDIF
CZIP += ":\DATA.ZIP"
MSGINFO("Veuillez insérer votre disque de sauvegarde")
IF ! FILE( cZip )
ALERT("Fichier Zip introuvable ! ")
RETURN NIL
ENDIF
DEFINE DIALOG oDlg RESOURCE "unzip"
REDEFINE SAY oSource PROMPT cZIP ID 101 OF oDlg
REDEFINE SAY oTarget PROMPT cPATH ID 102 OF oDlg
REDEFINE GET OFILE VAR DFILE ID 103 OF ODLG READONLY UPDATE COLOR CLR_HRED
REDEFINE METER oMEtEr VAR nPerc1 ID 150 OF oDlg TOTAL 100
REDEFINE BUTTON OBTNOK ID 01 OF oDlg ;
ACTION (OBTNOK:DISABLE(),OBTNCAN:DISABLE(),UNZIPME(CZIP,OMETER,cPATH,@LSAVE,SOUSREP,ODLG,@DFILE,OFILE))
REDEFINE BUTTON OBTNCAN ID 02 OF oDlg ;
ACTION LSAVE := .F., oDlg:end()
ACTIVATE DIALOG oDlg CENTERED
IF LSAVE
ECRSTAT("R")
ENDIF
tone( 500,1 )
tone( 600,1 )
tone( 700,1 )
MSGINFO("Restitution terminée")
RETURN NIL
STATIC FUNCTION UNZIPME(CZIP,OMETER,cPATH,LSAVE,SOUSREP,ODLG,DLGFILE,OBJFILE)
LOCAL cCurdir, cZipDir, ;
lZipWithPath := .T., ;
aFiles := {}, ;
NCTR := 0, ;
NLEN := 0
aFiles := hb_GetFilesInZip( CZIP ,.t.)
nLEN := len(afiles)
cCurdir:=cZipdir:=CURDRIVE()+":"+CURDIR()+""
SwitchDir("")
cZipdir:="."
IF ! HB_UNZIPFILE( cZip, {|cFile,nPos| UPDMETER(CFILE,OMETER,NPOS,@nctr,NLEN,ODLG,@DLGFILE,OBJFILE)}, lZipWithPath,, cZipdir )
ALERT("Erreur décompression fichiers")
RETURN NIL
ELSE
LSAVE := .T.
ENDIF
SwitchDir( cCurdir )
ODLG:END()
RETURN NIL
STATIC FUNCTION SwitchDir( cDir )
LOCAL nError:=0
nError:=DIRCHANGE( cDir )
SWITCH nError
CASE 0
EXIT
CASE -1
ALERT("Mauvais Paramètre")
EXIT
CASE 3
ALERT( "Ce dossier n'esiste pas "+cDir )
EXIT
CASE 5
ALERT("Accès refusé au dossier "+cDir )
EXIT
DEFAULT
ALERT( "Erreur inconnue : "+ALLTRIM( STR( nError ) )+" pour "+cDir )
END
IF nError <> 0
RETURN NIL
ENDIF
RETURN NIL