Page 4 of 5

Re: Backup & Restore Dbf Files

Posted: Wed Mar 28, 2012 12:58 pm
by mol
Problem lays in these lines:

Code: Select all

aTemp := DIRECTORY( BackUp.T_SourceFolder.Value + "\*.*" )
   
   AEVAL( aTemp, { | a1 | AADD( aFilesToBackup, a1[ 1 ] ) } )
   
   IF EMPTY( aFilesToBackup )
      MsgStop( "No file found to backup !", " ERROR !" )    
   ELSE
      BackUp.ProgressIndicator.RangeMax := len(aFilesToBackup)
      BackUp.ProgressIndicator.Value := 0

      COMPRESS aFilesToBackup ;
         TO cArchiveName ;
         BLOCK {|cFile,nPos|  BackUp.ProgressIndicator.Value := nPos }  ;
         OVERWRITE
	
      lBackupStatus  := .t.
      msgbox("Backup created successful!") 
They should be:

Code: Select all

  aTemp := DIRECTORY( BackUp.T_SourceFolder.Value + "\*.*" )
   
   AEVAL( aTemp, { | a1 | AADD( aFilesToBackup, BackUp.T_SourceFolder.Value + "\"+ a1[ 1 ] ) } )
   
   IF EMPTY( aFilesToBackup )
      MsgStop( "No file found to backup !", " ERROR !" )    
   ELSE
      BackUp.ProgressIndicator.RangeMax := len(aFilesToBackup)
      BackUp.ProgressIndicator.Value := 0

      COMPRESS aFilesToBackup ;
         TO cArchiveName ;
         BLOCK {|cFile,nPos|  BackUp.ProgressIndicator.Value := nPos }  ;
         OVERWRITE
	
      lBackupStatus  := .t.
      msgbox("Backup created successful!") 
Another way is to change current dir to folder being compressed.

The problem is, that version does not compress subdirectories of selected location :(

Re: Backup & Restore Dbf Files

Posted: Thu Mar 29, 2012 11:50 am
by esgici
Hi all

Please forgive me for disturbing :(

Found source of error: it's my fault :(

Our COMPRESS command doesn't have any problem :)

Again, sorry for false report :(

Best regards

--

Esgici

Re: Backup & Restore Dbf Files

Posted: Thu Mar 29, 2012 1:24 pm
by Rathinagiri
No problem Esgici. :)

Re: Backup & Restore Dbf Files

Posted: Thu Mar 29, 2012 2:17 pm
by mol
Didn't you try to build archiving with subdirectories?
Marek

Re: Backup & Restore Dbf Files

Posted: Thu Mar 29, 2012 2:37 pm
by esgici
Hi Mol
mol wrote:Didn't you try to build archiving with subdirectories?
Marek
I am working on it (with others).

I gues it's possible, but require a little extra effort; such as recursion.

And I guess also, if <aFiles> include path info together file names, COMPRESS store its in the result (.zip) file.

But sadly, Windows doesn't show content of such (including path infos) archive files :(

If I will reach a acceptable result, I will inform you.

Regards.

--

Esgici

Re: Backup & Restore Dbf Files

Posted: Tue Apr 03, 2012 7:50 pm
by danielmaximiliano
Hola muchachos:
perdon por hacer esta pregunta tonta.
modificando Zipdemo de HMG3.0.40
C:\hmg.3.0.40\SAMPLES\ZIP
los pasos se hacen correctamente, pero al abrir el archivo compactado me encuentro que esta vacio..
utilizando el depurador veo que toma el contenido de la carpeta en cuestion.

uso este ejemplo ya que tengo algo parecido para el respaldo de mi aplicacion y me hace lo mismo.
donde fallo ????

/****************** Translate Google *************************/
*********************************************************
Hi guys:
sorry for asking this silly question.
modifying Zipdemo of HMG3.0.40
C:\hmg.3.0.40\SAMPLES\ZIP
steps are done correctly, but when you open the zip file is empty I find that ..
using the debugger I see that takes the contents of the folder in question.

use this example because I have something similar to the support of my application and I do the same.
where failure ?????

Code: Select all

#include "hmg.ch"

Function main()
	DEFINE WINDOW form_1 ; 
		AT 114,218 ;
		WIDTH 334 ;
		HEIGHT 276 ; 
		TITLE 'ZIP TEST' ; 
		MAIN 

		DEFINE MAIN MENU

			DEFINE POPUP "Test"
				MENUITEM 'Create Zip' ACTION CreateZip()
			END POPUP

		END MENU

		@ 80,120 PROGRESSBAR Progress_1 RANGE 0,10 SMOOTH

		@ 120,120 LABEL label_1 VALUE ''


	END WINDOW 

	form_1.center
	form_1.activate

Return NIL

*------------------------------------------------------------------------------*
Function CreateZip()
*------------------------------------------------------------------------------*
local aDir:=Directory("Text\*.txt")
local afiles:={}
Local x
local nLen

	For x:=1 to len(aDir)
	    aadd(afiles,adir[x,1])
	next

	COMPRESS afiles ;
		TO 'c:\ZipTest.Zip' ;
		BLOCK {|cFile,nPos| ProgressUpdate( nPos , cFile ) }  ;
		OVERWRITE

Return nil

*------------------------------------------------------------------------------*
function ProgressUpdate(nPos , cFile )
*------------------------------------------------------------------------------*

	Form_1.Progress_1.Value := nPos
	Form_1.Label_1.Value := cFile

Return Nil
CZIPzipdemo.png
CZIPzipdemo.png (87.59 KiB) Viewed 3155 times
Text_2012-04-03_16-32-02.png
Text_2012-04-03_16-32-02.png (141.41 KiB) Viewed 3155 times
ZipTest.png
ZipTest.png (64.63 KiB) Viewed 3155 times

Re: Backup & Restore Dbf Files

Posted: Tue Apr 03, 2012 8:05 pm
by esgici
aadd(afiles,"text\"+adir[x,1]) // Line 40

Re: Backup & Restore Dbf Files

Posted: Thu Jul 05, 2012 10:04 pm
by paimar
First off all sorry for my horrible english.

If there is not a "clean" solution for making a backup of subdirectories I'm thinking in a very "dirty" solution :)

May be go throgh all directories and copy the files I need to one only directory. For the restore do the opposite.


Ahggg que alivio escribir en espaƱol :) Si no hay una solucion mas limpia para el tema de hacer backups de directorios con subdirectorios estoy pensando
en ir por los subdirectorios y copiar todos los archivos a un unico directorio y luego comprimir este. Para el restore se haria a la inversa copiando segun el tipo
de archivo a su directorio Dbf's a directorio dbf jpg's a directorio jpg etc.

Seria posible no?

un saludo

Re: Backup & Restore Dbf Files

Posted: Thu Jul 05, 2012 10:21 pm
by IMATECH
I think it's not a "clean" solution: But Works Well :)

Code: Select all


  LOCAL sCMD := 'WINRAR.EXE a -v -r BK_' + DTOS( DATE() ) + ' *.DB? *.JPG'
  HB_RUN( sCMD )



IF you have time... then can use a Better solution using "HB_DirScan(...)"

See the sample at:
\Harbour\contrib\hbmzip\tests\myzip.prg
\Harbour\contrib\hbmzip\tests\myunzip.prg

Code: Select all


PROCEDURE Main( ... )
   LOCAL hZip, aDir, aFile, aWild, ;
         cZipName, cPath, cFileName, cExt, cWild, cPassword, cComment,;
         tmp

   aWild := { ... }
   IF LEN(aWild) < 2
      ? "Usage: myzip <ZipName> [ --pass <password> ] [ --comment <comment> ] <FilePattern1> [ <FilePattern2> ... ]"
      RETURN
   ENDIF

   HB_FNameSplit( aWild[ 1 ], @cPath, @cFileName, @cExt )
   IF EMPTY( cExt )
      cExt := ".zip"
   ENDIF
   cZipName := HB_FNameMerge( cPath, cFileName, cExt )

   HB_ADEL( aWild, 1, .T. )

   FOR tmp := LEN( aWild ) - 1 TO 1 STEP -1
      IF LOWER( aWild[ tmp ] ) == "--pass"
         IF EMPTY( cPassword )
            cPassword := aWild[ tmp + 1 ]
         ENDIF
         aWild[ tmp ] := ""
         aWild[ tmp + 1 ] := ""
      ELSEIF LOWER( aWild[ tmp ] ) == "--comment"
         IF EMPTY( cComment )
            cComment := aWild[ tmp + 1 ]
         ENDIF
         aWild[ tmp ] := ""
         aWild[ tmp + 1 ] := ""
      ENDIF
   NEXT

   hZip := HB_ZIPOPEN( cZipName )
   IF ! EMPTY( hZip )
      ? "Archive file:", cZipName
      FOR EACH cWild IN aWild
         IF !EMPTY( cWild )
            HB_FNameSplit( cWild, @cPath, @cFileName, @cExt )
            aDir := HB_DirScan( cPath, cFileName + cExt )
            FOR EACH aFile IN aDir
               IF ! cPath + aFile[ 1 ] == cZipName
                  ? "Adding", cPath + aFile[ 1 ]
                  HB_ZipStoreFile( hZip, cPath + aFile[ 1 ], cPath + aFile[ 1 ], cPassword )
               ENDIF
            NEXT
         ENDIF
      NEXT
      HB_ZIPCLOSE( hZip, cComment )
   ENDIF

RETURN


Re: Backup & Restore Dbf Files

Posted: Wed Jul 17, 2013 9:17 am
by AidTIC
perdon, a ver si me podeis ayudar.

He retocado el programa que viene con HMG.3.0.46 de Zip. Para que me comprima 2 DBF que tengo en un subdirectorio.

Y me crea el .zip perfectamente. pero no consigo que termine el programa. se queda asi:

Image

El boton de Aceptar siempre esta activo.
Donde esta fallando?

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include "hmg.ch"

Function main()

DEFINE WINDOW form_1 ;
AT 114,218 ;
WIDTH 334 ;
HEIGHT 276 ;
TITLE 'ZIP TEST' ;
MAIN

DEFINE MAIN MENU

DEFINE POPUP "Test"
MENUITEM 'Create Zip' ACTION CreateZip()
END POPUP

END MENU

@ 80,120 PROGRESSBAR Progress_1 RANGE 0,10 SMOOTH

@ 120,120 LABEL label_1 VALUE ''

DEFINE BUTTON Boton_Ac
ROW 170
COL 100
WIDTH 150
HEIGHT 48
CAPTION ' Aceptar '
FONTNAME "Arial"
FONTSIZE 18
FONTBOLD .T.
ONCLICK form_1.Release // Iif (MsgOkCancel ("Desea Enviar Los Ficheros?", "Envio de Ficheros") , MainCreateZip() , Win_ENLA.Release)
HELPID "Aceptar"
VISIBLE .T.
END BUTTON



END WINDOW

form_1.center
form_1.activate
form_1.Boton_Ac.Enabled := .f.

Return NIL

*------------------------------------------------------------------------------*
Function CreateZip()
*------------------------------------------------------------------------------*
local aDir:=Directory("Enlace\*.DBF")
local afiles:={}
Local x
local nLen

For x:=1 to len(aDir)
aadd(afiles,"Enlace\"+adir[x,1])
next

COMPRESS afiles ;
TO 'ZipTest.Zip' ;
BLOCK {|cFile,nPos| ProgressUpdate( nPos , cFile ) } ;
OVERWRITE


form_1.Boton_Ac.Enabled := .T.
Return nil

*------------------------------------------------------------------------------*
function ProgressUpdate(nPos , cFile )
*------------------------------------------------------------------------------*

Form_1.Progress_1.Value := nPos
Form_1.Label_1.Value := cFile

Return Nil
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *