Unicode C
Unicode C
Uncompress a Gzip File to a Specific Output File
See more Gzip Examples
This example demonstrates how to use the UncompressFile method to decompress a Gzip (.gz) file and write the uncompressed data to a specified output file.
The method reads the compressed input file and writes the decompressed contents to the output path provided. The output filename is explicitly specified by your application and does not depend on the filename embedded within the Gzip file.
This provides full control over where and how the decompressed file is created.
Chilkat Unicode C Downloads
#include <C_CkGzipW.h>
void ChilkatSample(void)
{
BOOL success;
HCkGzipW gzip;
const wchar_t *gzPath;
const wchar_t *outPath;
success = FALSE;
// This example demonstrates how to uncompress a Gzip (.gz) file
// and write the uncompressed output to a specified file.
gzip = CkGzipW_Create();
// The input Gzip file and output file:
gzPath = L"example.txt.gz";
outPath = L"output.txt";
// Uncompress the file:
success = CkGzipW_UncompressFile(gzip,gzPath,outPath);
if (success == FALSE) {
wprintf(L"%s\n",CkGzipW_lastErrorText(gzip));
CkGzipW_Dispose(gzip);
return;
}
wprintf(L"Gzip file successfully uncompressed.\n");
wprintf(L"Output file: %s\n",outPath);
CkGzipW_Dispose(gzip);
}