Page 1 of 5
Backup & Restore Dbf Files
Posted: Fri May 15, 2009 1:45 pm
by sudip
Hi All,
I was experimenting how to zip and unzip files with HMG.
I found that existing COMPRESS and UNCOMPRESS don't fulfill what I want.
So, I "learned" to use low level hb_ commands. Moreover I used the GetSaveFileName() and
GetOpenFileName() functions (Win32 functions if I am not wrong) here.
(Thank you Rathi. I got the "courage" from you to use low level functions.)
- BackRest.jpg (16.95 KiB) Viewed 10166 times
Please downlowd
. Compile and run.
And please tell me how to upgrade this project.
It is very useful for learning HMG.
With best regards.
Sudip
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:18 pm
by esgici
Hi Sudip
sudip wrote:Please download, Compile and run.
Done, but unfortunately :
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1c8): undefined reference to `HB_FUN_HB_ZIPFILE'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1d8): undefined reference to `HB_FUN_HB_GETFILESINZIP'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1e8): undefined reference to `HB_FUN_HB_UNZIPFILE'
mingw32-make.exe: *** [...\Sudip\BackRest\MAIN.exe] Error 1
Finished With Errors.
What I missed ?
BTW, why you don't use
CompressFiles(),
UncompressFiles() functions or
COMPRESS,
UNCOMPRESS commands of HMG?
Regards
--
Esgici
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:23 pm
by Vanguarda
Hi friends,
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1c8): undefined reference to `HB_FUN_HB_ZIPFILE'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1d8): undefined reference to `HB_FUN_HB_GETFILESINZIP'
...\Sudip\BackRest\MAIN.o:MAIN.c:(.data+0x1e8): undefined reference to `HB_FUN_HB_UNZIPFILE'
mingw32-make.exe: *** [...\Sudip\BackRest\MAIN.exe] Error 1
Finished With Errors.
It occurs whit me too.
Regards,
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:33 pm
by sudip
Hello,
Please run HMG IDE. Then go to Tools -> Preferences. Then in the External Libraries text box, please type
I hope this will solve the problem.
With best regards.
Sudip
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:34 pm
by Rathinagiri
Something is missed out here, I think.
I am using compressfiles() & uncompressfiles()
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:38 pm
by sudip
Hi Esgici,
Thank you for testing
esgici wrote:
BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?
I tried those commands. But I can't found how to unzip into a SPECIFIC FOLDER. So, I HAD TO USE low level functions of harbour libraries. If there is an EASIER way to do it with UNCOMPRESS command, please inform me (as you know, I am in a very basic learner of HMG)
With best regards.
Sudip
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:40 pm
by sudip
Hi Rathi,
rathinagiri wrote:Something is missed out here, I think.
I am using compressfiles() & uncompressfiles()
Yes, 3 libraries (may be 1 is sufficient. But I have to test it)
With best regards.
Sudip
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:42 pm
by Vanguarda
Hi friend Sudip,
It working fine.
Very good you code.
you learn very good, the low level. Good luck with your tests
i know that this is only a example of low level. but for compress and make a backup, i agree with Esgici:
"BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?"
When you get a another code post for us, guy. Please go ahead with their functions and codes on the low level.
This was very good. Congratulations.
PS: Sorry my bad english
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:45 pm
by sudip
Hi All,
I got following documentation for HB_UNZIPFILE function.
Code: Select all
HB_UNZIPFILE()
Unzip a compressed file
Syntax
HB_UNZIPFILE( <cFile>, <bBlock>, <lWithPath>, <cPassWord>, <cPath>,
<cFile> | <aFile>, <pFileProgress> ) ---> lCompress
Arguments
<cFile> Name of the zip file to extract
<bBlock> Code block to execute while extracting
<lWithPath> Toggle to create directory if needed
<cPassWord> Password to use to extract files
<cPath> Path to extract the files to - mandatory
<cFile> | <aFiles> A File or Array of files to extract - mandatory
<pFileProgress> Code block for File Progress
Returns
<lCompress> .t. if all file was successfully restored, otherwise .f.
Description
This function restores all files contained inside the <cFile>. If the extension is omitted, .ZIP will be assumed. If a file already exists, it will be overwritten.
If <bBlock> is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.
The <cPath> is a mandatory parameter. Set to ".\" to extract to the current directory
If <cFile> or <aFiles> are not provided, no files will be extracted! Make sure you provide the file or files you want extracted
If <pFileProgress> is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {|nPos,nTotal| GaugeUpdate(aGauge1,(nPos/nTotal))}
Examples
FUNCTION MAIN()
aExtract := hb_GetFilesInZip( "TEST.ZIP" ) // extract all files in zip
IF HB_UNZIPFILE( "TEST.ZIP",,,, ".\", aExtract )
qout("File was successfully extracted")
ENDIF
aExtract := hb_GetFilesInZip( "TEST2.ZIP" ) // extract all files in zip
IF HB_UNZIPFILE( "TEST2.ZIP", {|cFile| qout( cFile ) },,, ".\", aExtract )
qout("File was successfully extracted")
ENDIF
Return Nil
Status
Ready
Compliance
This function is a Harbour extension
Platforms
All
Files
Library is hbzip.lib
I think this function has more options than CompressFiles() function.
Please send your comments. It is essential for my journey in HMG.
With best regards.
Sudip
Re: Backup & Restore Dbf Files
Posted: Fri May 15, 2009 2:50 pm
by Rathinagiri
Thanks Sudip. My way of doing.
Code: Select all
zipname := "x.zip"
fnames := array(adir("c:\folder\*.*"))
adir("c:\folder\*.*",fnames)
compressfilesarr := {}
for i := 1 to len(fnames)
aadd(compressfilesarr,"c:\folder\"+alltrim(fnames[i]))
next i
Then we can use compress files command.
Regarding recursive sub-directories, we have to work more.