Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
bz2 Compress File
Compress a file to the bz2 file format.Chilkat Pascal (Lazarus/Delphi) Downloads
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.Bz2;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
bz2: TBz2;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
bz2 := TBz2.Create;
// Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
success := bz2.CompressFile('qa_data/hamlet.xml','qa_output/hamlet.bz2');
if (success <> True) then
begin
WriteLn(bz2.LastErrorText);
Exit;
end;
WriteLn('Success.');
bz2.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.