Sample code for 30+ languages & platforms
PowerBuilder

Check if a File is in Gzip Format

See more Gzip Examples

This example demonstrates how to use the ExamineFile method to determine whether a file is in Gzip format.

The method inspects the contents of the specified file and returns true if the file is recognized as a valid Gzip file, or false if it is not. This is useful for validating input files before attempting to decompress them.

If the method fails (for example, if the file does not exist or cannot be accessed), the CHECK_SUCCESS macro reports the error.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Gzip
string ls_FilePath
integer li_IsGzip

// This example demonstrates how to determine if a file is in Gzip format.

loo_Gzip = create oleobject
li_rc = loo_Gzip.ConnectToNewObject("Chilkat.Gzip")
if li_rc < 0 then
    destroy loo_Gzip
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// The file to examine:
ls_FilePath = "test.gz"

// Check if the file is a valid Gzip file:
li_IsGzip = loo_Gzip.ExamineFile(ls_FilePath)

if li_IsGzip = 1 then
    Write-Debug "The file is a valid Gzip file."
else
    Write-Debug "The file isnot a Gzip file."
end if



destroy loo_Gzip