Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

GZip Decompress File

See more Gzip Examples

Demonstrates how to uncompress a .gz compressed file to get the uncompressed original file.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Gzip;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  gzip: TGzip;

begin
  success := False;

  //  This example assumes the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  gzip := TGzip.Create;

  success := gzip.UncompressFile('qa_data/gzip/something.csv.gz','qa_output/something.csv');
  if (success <> True) then
    begin
      WriteLn(gzip.LastErrorText);
      Exit;
    end;

  WriteLn('File successfully uncompressed and extracted from the Gzip compressed format.');


  gzip.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.