Hi FiveWinners
Is there a library that packs in zip format the contents of a vriable in memory?
That is, it does not generate any files to disk in the process of unpacking and unpacking? and that the method returns the packaged variable ...
Anyone know the trick?
Regards
Packing zip in memory
Packing zip in memory
Visite Chiapas, el paraiso de México.
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Re: Packing zip in memory
Hi,
If you are using xHarbour, The following code is from xHarbour Help. May be it is useful to you.
-Ramesh Babu P
If you are using xHarbour, The following code is from xHarbour Help. May be it is useful to you.
Code: Select all
// The example implements two functions for easiest (un)compression
// since the buffer size required for uncompression is stored in
// the compressed string using HB_CreateLen8().
PROCEDURE Main
LOCAL cText := MemoRead( "LargeFile.txt" )
LOCAL cCompressed, cUncompressed
cCompressed := ZipCompress( cText )
cUnCompressed := ZipUncompress( cCompressed )
? "Original :", Len( cText )
? "Compressed :", Len( cCompressed )
? "Uncompressed:", Len( cUncompressed )
? cUncompressed == cText
RETURN
// The function adds 8 bytes holding the length of the original
// character string to the compressed string
FUNCTION ZipCompress( cString )
LOCAL cCompressed := HB_Compress( cString )
RETURN HB_CreateLen8( Len( cString ) ) + cCompressed
// The function extracts the first 8 bytes holding the length
// of the uncompressed character string from the compressed string
FUNCTION ZipUncompress( cCompressed )
LOCAL nBytes := HB_GetLen8( cCompressed )
RETURN HB_Uncompress( nBytes, SubStr( cCompressed, 9 ) )