DataFlex
DataFlex
Decompress Gzip Data from BinData Directly to a File
See more Gzip Examples
This example demonstrates how to use the UncompressBdToFile method to decompress Gzip data stored in a BinData object and write the uncompressed output directly to a file.
The compressed .gz data is first loaded into memory using a BinData object. The UncompressBdToFile method then decompresses the data and writes the result directly to the specified file, without modifying the contents of the BinData object.
This approach is useful when you want to extract compressed data to disk without performing an in-place transformation or managing intermediate buffers.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoGzip
Variant vBd
Handle hoBd
String sTemp1
Move False To iSuccess
// This example demonstrates how to decompress Gzip data stored in a BinData object
// and write the uncompressed output directly to a file.
Get Create (RefClass(cComChilkatGzip)) To hoGzip
If (Not(IsComObjectCreated(hoGzip))) Begin
Send CreateComObject of hoGzip
End
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
// Load a .gz file into BinData:
Get ComLoadFile Of hoBd "example.txt.gz" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoBd To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Loaded Gzip data into memory."
// Uncompress the Gzip data and write directly to a file:
Get pvComObject of hoBd to vBd
Get ComUncompressBdToFile Of hoGzip vBd "example.txt" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoGzip To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "File successfully uncompressed to example.txt"
End_Procedure