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

UnGzip .tgz to get a .tar

See more Tar Archive Examples

A .tgz is simply a TAR archive compressed using GZip. It is also commonly referred to as a .tar.gz. Chilkat GZip can be used to ungzip to get an uncompressed .tar.

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;

  gzip := TGzip.Create;

  success := gzip.UncompressFile('qa_data/tar/test.tgz','qa_output/test.tar');
  if (success <> True) then
    begin
      WriteLn(gzip.LastErrorText);
    end
  else
    begin
      WriteLn('success.');
    end;


  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.