UNCOMPRESS command extension

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

Post Reply
User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

UNCOMPRESS command extension

Post by sudip » Wed Sep 23, 2009 7:09 am

Hello Master Roberto,

Is it possible to add EXTRACTPATH in UNCOMPRESS command?
Following command syntax is taken from HMG Extended manual.

Code: Select all

UNCOMPRESS [ FILE ] <cZipFile>
EXTRACTPATH <cExtractPath>
[ BLOCK <bBlock> ]
[ CREATEDIR ]
[ PASSWORD <cPassword> ] 
Moreover is there any way to know number files in a compressed (zip) file beforehand for showing status of progressbar correctly? I can't do it. So I used my low level UDF to do this.

With best regards.

Sudip
With best regards,
Sudip

User avatar
Roberto Lopez
HMG Founder
Posts: 3900
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 136 times

Post by Roberto Lopez » Wed Sep 23, 2009 1:24 pm

sudip wrote:Hello Master Roberto,

Is it possible to add EXTRACTPATH in UNCOMPRESS command?
Following command syntax is taken from HMG Extended manual.

Code: Select all

UNCOMPRESS [ FILE ] <cZipFile>
EXTRACTPATH <cExtractPath>
[ BLOCK <bBlock> ]
[ CREATEDIR ]
[ PASSWORD <cPassword> ] 
Moreover is there any way to know number files in a compressed (zip) file beforehand for showing status of progressbar correctly? I can't do it. So I used my low level UDF to do this.

With best regards.

Sudip
This is the reference of HMBZip contribution:
Harbour functions to mange ZIP files:
=====================================

HB_ZipOpen( cFileName, [ iMode = HB_ZIP_CREATE ],
[ @cGlobalComment ] ) --> hZip
HB_ZipClose( hZip, [ cGlobalComment ] ) --> nError
HB_ZipFileCreate( hZip, cZipName, tDateTime, cTime,
nInternalAttr, nExternalAttr,
[ nMethod = HB_ZLIB_METHOD_DEFLATE ],
[ nLevel = HB_ZLIB_COMPRESSION_DEFAULT ],
[ cPassword, ulFileCRC32 ], [ cComment ] ) --> nError
HB_ZipFileWrite( hZip, cData [, nLen ] ) --> nError
HB_ZipFileClose( hZip ) --> nError
HB_ZipStoreFile( hZip, cFileName, [ cZipName ], ;
[ cPassword ], [ cComment ] ) --> nError
HB_ZipStoreFileHandle( hZip, fhnd, cZipName, ;
[ cPassword ], [ cComment ] ) --> nError
HB_zipFileCRC32( cFileName ) --> nError


HB_UnzipOpen( cFileName ) --> hUnzip
HB_UnzipClose( hUnzip ) --> nError
HB_UnzipGlobalInfo( hUnzip, @nEntries, @cGlobalComment ) --> nError
HB_UnzipFileFirst( hUnzip ) --> nError
HB_UnzipFileNext( hUnzip ) --> nError
HB_UnzipFilePos( hUnzip ) --> nPosition
HB_UnzipFileGoto( hUnzip, nPosition ) --> nError
HB_UnzipFileInfo( hUnzip, @cZipName, @tDateTime, @cTime,
@nInternalAttr, @nExternalAttr,
@nMethod, @nSize, @nCompressedSize,
@lCrypted, @cComment ) --> nError
HB_UnzipFileOpen( hUnzip, [ cPassword ] ) --> nError
HB_UnzipFileRead( hUnzip, @cBuf [, nLen ] ) --> nRead
HB_UnzipFileClose( hUnzip ) --> nError
HB_UnzipExtractCurrentFile( hUnzip, [ cFileName ], [ cPassword ] ) --> nError
HB_UnzipExtractCurrentFileToHandle( hZip, fhnd, [ cPassword ] ) --> nError


HB_ZipDeleteFile( cZipFile, cFileMask ) --> nError
Which function had you used to get file count?

What idea had you about to use that info in the UNCOMPRESS commad?

TIA.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Wed Sep 23, 2009 2:08 pm

Hello Master Roberto,
Roberto Lopez wrote: ...
Which function had you used to get file count?
...
I used following code

Code: Select all

    aFiles := HB_GetFilesInZip(cZipFile)
    
    main.pbRestore.value := 0
    main.pbRestore.visible := .t.
    	
    HB_UnzipFile(cZipFile, {|cFile,nPos| main.pbRestore.value := nPos/len(aFiles)*100 },,, cFolder+"\", aFiles)

    main.pbRestore.value := 0
    main.pbRestore.visible := .f.
It will be helpful if we have:-
1) Last but one parameters of HB_UnzipFile function i.e., cFolder+"\" as extract folder path parameter in UNCOMPRESS command.
2) Array of files in Zip file, ie, using HB_GetFilesInZip(cZipFile) function.
Especially 1st point will be very helpful, if possible.
As a learner of HMG, I assume HB_... functions are low level functions. So, is it better to use high level functions if available?

With best regards.

Sudip
With best regards,
Sudip

User avatar
Roberto Lopez
HMG Founder
Posts: 3900
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 136 times

Post by Roberto Lopez » Wed Sep 23, 2009 4:02 pm

sudip wrote:Hello Master Roberto,
Roberto Lopez wrote: ...
Which function had you used to get file count?
...
I used following code

Code: Select all

    aFiles := HB_GetFilesInZip(cZipFile)
    
    main.pbRestore.value := 0
    main.pbRestore.visible := .t.
    	
    HB_UnzipFile(cZipFile, {|cFile,nPos| main.pbRestore.value := nPos/len(aFiles)*100 },,, cFolder+"\", aFiles)

    main.pbRestore.value := 0
    main.pbRestore.visible := .f.
It will be helpful if we have:-
1) Last but one parameters of HB_UnzipFile function i.e., cFolder+"\" as extract folder path parameter in UNCOMPRESS command.
2) Array of files in Zip file, ie, using HB_GetFilesInZip(cZipFile) function.
Especially 1st point will be very helpful, if possible.
As a learner of HMG, I assume HB_... functions are low level functions. So, is it better to use high level functions if available?

With best regards.

Sudip
The function you've used belongs to other contrib library ("ZipArchive interface compatibility implementation").

I guess that there is no problem in using it, but I'm not figurung out how to use in 'UnCompress' command.


Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Thu Sep 24, 2009 6:22 am

Hello Master Roberto,
Roberto Lopez wrote: The function you've used belongs to other contrib library ("ZipArchive interface compatibility implementation").
I guess that there is no problem in using it, but I'm not figurung out how to use in 'UnCompress' command.
Thanks a lot.
Yes, you are correct. I forgot it :(. I first used these functions with xHarbour. Then I used them with HMG.
Now, I shall try the functions you mentioned.

I have 3 wishes for COMPRESS command also:-
1) I found that full path of the files are stored within zip file. Is it possible to have an option, not to store this path?
2) Option to specify Compression Level.
3) Option for password protection.

Above points are my wishes only. Now, you can better decide whether those points are essential or not :)

With best regards.

Sudip
With best regards,
Sudip

User avatar
Roberto Lopez
HMG Founder
Posts: 3900
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 136 times

Post by Roberto Lopez » Thu Sep 24, 2009 12:48 pm

sudip wrote:Hello Master Roberto,
Roberto Lopez wrote: The function you've used belongs to other contrib library ("ZipArchive interface compatibility implementation").
I guess that there is no problem in using it, but I'm not figurung out how to use in 'UnCompress' command.
Thanks a lot.
Yes, you are correct. I forgot it :(. I first used these functions with xHarbour. Then I used them with HMG.
Now, I shall try the functions you mentioned.

I have 3 wishes for COMPRESS command also:-
1) I found that full path of the files are stored within zip file. Is it possible to have an option, not to store this path?
2) Option to specify Compression Level.
3) Option for password protection.

Above points are my wishes only. Now, you can better decide whether those points are essential or not :)

With best regards.

Sudip
As far as I remember (I should check it) the 'ZipArchive' contribution is new to Harbour 2.0.

I plan to start making test builds with Harbour 2.0 soon.

If you have any code to enhance Compress/Uncompress commands, please, post it.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

Post Reply