Backup & Restore Dbf Files
Moderator: Rathinagiri
Backup & Restore Dbf Files
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.) 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
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.) 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
With best regards,
Sudip
Sudip
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Backup & Restore Dbf Files
Hi Sudip
BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?
Regards
--
Esgici
Done, but unfortunately :sudip wrote:Please download, Compile and run.
What I missed ?...\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.
BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?
Regards
--
Esgici
Viva INTERNATIONAL HMG
Re: Backup & Restore Dbf Files
Hi friends,
It occurs whit me too.
Regards,
...\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
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
Please run HMG IDE. Then go to Tools -> Preferences. Then in the External Libraries text box, please type
Code: Select all
hbziparc;hbmzip;hbzlib
With best regards.
Sudip
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Backup & Restore Dbf Files
Something is missed out here, I think.
I am using compressfiles() & uncompressfiles()
I am using compressfiles() & uncompressfiles()
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Backup & Restore Dbf Files
Hi Esgici,
Thank you for testing
With best regards.
Sudip
Thank you for testing
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)esgici wrote: BTW, why you don't use CompressFiles(), UncompressFiles() functions or COMPRESS, UNCOMPRESS commands of HMG?
With best regards.
Sudip
With best regards,
Sudip
Sudip
Re: Backup & Restore Dbf Files
Hi Rathi,
With best regards.
Sudip
Yes, 3 libraries (may be 1 is sufficient. But I have to test it)rathinagiri wrote:Something is missed out here, I think.
I am using compressfiles() & uncompressfiles()
With best regards.
Sudip
With best regards,
Sudip
Sudip
Re: Backup & Restore Dbf Files
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
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
Hi All,
I got following documentation for HB_UNZIPFILE function.
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
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
Please send your comments. It is essential for my journey in HMG.
With best regards.
Sudip
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Backup & Restore Dbf Files
Thanks Sudip. My way of doing.
Then we can use compress files command.
Regarding recursive sub-directories, we have to work more.
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
Regarding recursive sub-directories, we have to work more.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.