unit Chilkat.Tar;

{
  Pascal wrapper for Chilkat Tar.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

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

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TTar wraps CkTar via the C bridge layer. }
  TTar = class(TChilkatBase)
  private
    FOnAbortCheck: TChilkatAbortCheckEvent;
    FOnPercentDone: TChilkatPercentDoneEvent;
    FOnProgressInfo: TChilkatProgressInfoEvent;
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetCaptureXmlListing: Boolean;
    procedure SetCaptureXmlListing(AValue: Boolean);
    function  GetCharset: string;
    procedure SetCharset(AValue: string);
    function  GetDirMode: Integer;
    procedure SetDirMode(AValue: Integer);
    function  GetDirPrefix: string;
    procedure SetDirPrefix(AValue: string);
    function  GetFileMode: Integer;
    procedure SetFileMode(AValue: Integer);
    function  GetGroupId: Integer;
    procedure SetGroupId(AValue: Integer);
    function  GetGroupName: string;
    procedure SetGroupName(AValue: string);
    function  GetHeartbeatMs: Integer;
    procedure SetHeartbeatMs(AValue: Integer);
    function  GetMatchCaseSensitive: Boolean;
    procedure SetMatchCaseSensitive(AValue: Boolean);
    function  GetMustMatch: string;
    procedure SetMustMatch(AValue: string);
    function  GetMustNotMatch: string;
    procedure SetMustNotMatch(AValue: string);
    function  GetNoAbsolutePaths: Boolean;
    procedure SetNoAbsolutePaths(AValue: Boolean);
    function  GetNumDirRoots: Integer;
    function  GetPercentDoneScale: Integer;
    procedure SetPercentDoneScale(AValue: Integer);
    function  GetScriptFileMode: Integer;
    procedure SetScriptFileMode(AValue: Integer);
    function  GetSuppressOutput: Boolean;
    procedure SetSuppressOutput(AValue: Boolean);
    function  GetUntarCaseSensitive: Boolean;
    procedure SetUntarCaseSensitive(AValue: Boolean);
    function  GetUntarDebugLog: Boolean;
    procedure SetUntarDebugLog(AValue: Boolean);
    function  GetUntarDiscardPaths: Boolean;
    procedure SetUntarDiscardPaths(AValue: Boolean);
    function  GetUntarFromDir: string;
    procedure SetUntarFromDir(AValue: string);
    function  GetUntarMaxCount: Integer;
    procedure SetUntarMaxCount(AValue: Integer);
    function  GetUserId: Integer;
    procedure SetUserId(AValue: Integer);
    function  GetUserName: string;
    procedure SetUserName(AValue: string);
    function  GetWriteFormat: string;
    procedure SetWriteFormat(AValue: string);
    function  GetXmlListing: string;
    procedure SetXmlListing(AValue: string);
    procedure SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
    procedure SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
    procedure SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property CaptureXmlListing: Boolean read GetCaptureXmlListing write SetCaptureXmlListing;
    property Charset: string read GetCharset write SetCharset;
    property DirMode: Integer read GetDirMode write SetDirMode;
    property DirPrefix: string read GetDirPrefix write SetDirPrefix;
    property FileMode: Integer read GetFileMode write SetFileMode;
    property GroupId: Integer read GetGroupId write SetGroupId;
    property GroupName: string read GetGroupName write SetGroupName;
    property HeartbeatMs: Integer read GetHeartbeatMs write SetHeartbeatMs;
    property MatchCaseSensitive: Boolean read GetMatchCaseSensitive write SetMatchCaseSensitive;
    property MustMatch: string read GetMustMatch write SetMustMatch;
    property MustNotMatch: string read GetMustNotMatch write SetMustNotMatch;
    property NoAbsolutePaths: Boolean read GetNoAbsolutePaths write SetNoAbsolutePaths;
    property NumDirRoots: Integer read GetNumDirRoots;
    property PercentDoneScale: Integer read GetPercentDoneScale write SetPercentDoneScale;
    property ScriptFileMode: Integer read GetScriptFileMode write SetScriptFileMode;
    property SuppressOutput: Boolean read GetSuppressOutput write SetSuppressOutput;
    property UntarCaseSensitive: Boolean read GetUntarCaseSensitive write SetUntarCaseSensitive;
    property UntarDebugLog: Boolean read GetUntarDebugLog write SetUntarDebugLog;
    property UntarDiscardPaths: Boolean read GetUntarDiscardPaths write SetUntarDiscardPaths;
    property UntarFromDir: string read GetUntarFromDir write SetUntarFromDir;
    property UntarMaxCount: Integer read GetUntarMaxCount write SetUntarMaxCount;
    property UserId: Integer read GetUserId write SetUserId;
    property UserName: string read GetUserName write SetUserName;
    property WriteFormat: string read GetWriteFormat write SetWriteFormat;
    property XmlListing: string read GetXmlListing write SetXmlListing;

    { Event callbacks.  Return True from OnAbortCheck / OnPercentDone
      to abort the running method.  Callbacks are invoked on the
      thread that called the Chilkat method.  The HeartbeatMs
      property controls the AbortCheck frequency. }
    property OnAbortCheck: TChilkatAbortCheckEvent read FOnAbortCheck write SetOnAbortCheck;
    property OnPercentDone: TChilkatPercentDoneEvent read FOnPercentDone write SetOnPercentDone;
    property OnProgressInfo: TChilkatProgressInfoEvent read FOnProgressInfo write SetOnProgressInfo;

    function  AddDirRoot(const dirPath: string): Boolean;
    function  AddFile(const path: string): Boolean;
    function  GetDirRoot(index: Integer): string;
    function  ListXml(const tarPath: string): string;
    function  Untar(const tarPath: string): Integer;
    function  UntarBz2(const tarPath: string): Boolean;
    function  UntarGz(const tarPath: string): Boolean;
    function  UntarZ(const tarPath: string): Boolean;
    function  VerifyTar(const tarPath: string): Boolean;
    function  WriteTar(const tarPath: string): Boolean;
    function  WriteTarBz2(const bz2Path: string): Boolean;
    function  WriteTarGz(const gzPath: string): Boolean;
    function  AddDirRoot2(const rootPrefix: string; const rootPath: string): Boolean;
    function  CreateDeb(const controlPath: string; const dataPath: string; const debPath: string): Boolean;
    function  AddFile2(const filePath: string; const pathWithinTar: string): Boolean;
    function  UntarFirstMatchingToBd(const tarPath: string; const matchPattern: string; bd: TChilkatBase): Boolean;
    function  ClearDirRootsAndFiles: Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkTar_Create  = function(): Pointer; cdecl;
  TCkTar_Dispose = procedure(handle: Pointer); cdecl;
  TCkBridgeAbortCheckCb   = function(userData: Pointer): Integer; cdecl;
  TCkBridgePercentDoneCb  = function(pctDone: Integer; userData: Pointer): Integer; cdecl;
  TCkBridgeProgressInfoCb = procedure(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
  TCkTar_SetAbortCheckCallback   = procedure(handle: Pointer; cb: TCkBridgeAbortCheckCb; userData: Pointer); cdecl;
  TCkTar_SetPercentDoneCallback  = procedure(handle: Pointer; cb: TCkBridgePercentDoneCb; userData: Pointer); cdecl;
  TCkTar_SetProgressInfoCallback = procedure(handle: Pointer; cb: TCkBridgeProgressInfoCb; userData: Pointer); cdecl;
  TCkTar_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_CaptureXmlListing = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_CaptureXmlListing = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_Charset = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_Charset = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_DirMode = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_DirMode = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_DirPrefix = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_DirPrefix = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_FileMode = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_FileMode = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_GroupId = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_GroupId = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_GroupName = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_GroupName = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_HeartbeatMs = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_HeartbeatMs = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_MatchCaseSensitive = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_MatchCaseSensitive = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_MustMatch = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_MustMatch = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_MustNotMatch = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_MustNotMatch = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_NoAbsolutePaths = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_NoAbsolutePaths = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_NumDirRoots = function(handle: Pointer): Integer; cdecl;
  TCkTar_get_PercentDoneScale = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_PercentDoneScale = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_ScriptFileMode = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_ScriptFileMode = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_SuppressOutput = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_SuppressOutput = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_UntarCaseSensitive = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_UntarCaseSensitive = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_UntarDebugLog = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_UntarDebugLog = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_UntarDiscardPaths = function(handle: Pointer): LongBool; cdecl;
  TCkTar_put_UntarDiscardPaths = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkTar_get_UntarFromDir = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_UntarFromDir = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_UntarMaxCount = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_UntarMaxCount = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_UserId = function(handle: Pointer): Integer; cdecl;
  TCkTar_put_UserId = procedure(handle: Pointer; value: Integer); cdecl;
  TCkTar_get_UserName = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_UserName = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_WriteFormat = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_WriteFormat = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_get_XmlListing = function(handle: Pointer): PAnsiChar; cdecl;
  TCkTar_put_XmlListing = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkTar_AddDirRoot = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkTar_AddFile = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkTar_GetDirRoot = function(handle: Pointer; index: Integer): PAnsiChar; cdecl;
  TCkTar_ListXml = function(handle: Pointer; tarPath: PAnsiChar): PAnsiChar; cdecl;
  TCkTar_Untar = function(handle: Pointer; tarPath: PAnsiChar): Integer; cdecl;
  TCkTar_UntarBz2 = function(handle: Pointer; tarPath: PAnsiChar): LongBool; cdecl;
  TCkTar_UntarGz = function(handle: Pointer; tarPath: PAnsiChar): LongBool; cdecl;
  TCkTar_UntarZ = function(handle: Pointer; tarPath: PAnsiChar): LongBool; cdecl;
  TCkTar_VerifyTar = function(handle: Pointer; tarPath: PAnsiChar): LongBool; cdecl;
  TCkTar_WriteTar = function(handle: Pointer; tarPath: PAnsiChar): LongBool; cdecl;
  TCkTar_WriteTarBz2 = function(handle: Pointer; bz2Path: PAnsiChar): LongBool; cdecl;
  TCkTar_WriteTarGz = function(handle: Pointer; gzPath: PAnsiChar): LongBool; cdecl;
  TCkTar_AddDirRoot2 = function(handle: Pointer; rootPrefix: PAnsiChar; rootPath: PAnsiChar): LongBool; cdecl;
  TCkTar_CreateDeb = function(handle: Pointer; controlPath: PAnsiChar; dataPath: PAnsiChar; debPath: PAnsiChar): LongBool; cdecl;
  TCkTar_AddFile2 = function(handle: Pointer; filePath: PAnsiChar; pathWithinTar: PAnsiChar): LongBool; cdecl;
  TCkTar_UntarFirstMatchingToBd = function(handle: Pointer; tarPath: PAnsiChar; matchPattern: PAnsiChar; bd: Pointer): LongBool; cdecl;
  TCkTar_ClearDirRootsAndFiles = function(handle: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkTar_Create:  TCkTar_Create  = nil;
  CkTar_Dispose: TCkTar_Dispose = nil;
  CkTar_SetAbortCheckCallback:   TCkTar_SetAbortCheckCallback   = nil;
  CkTar_SetPercentDoneCallback:  TCkTar_SetPercentDoneCallback  = nil;
  CkTar_SetProgressInfoCallback: TCkTar_SetProgressInfoCallback = nil;
  CkTar_get_LastErrorHtml: TCkTar_get_LastErrorHtml = nil;
  CkTar_get_LastErrorText: TCkTar_get_LastErrorText = nil;
  CkTar_get_LastErrorXml: TCkTar_get_LastErrorXml = nil;
  CkTar_get_Version: TCkTar_get_Version = nil;
  CkTar_get_DebugLogFilePath: TCkTar_get_DebugLogFilePath = nil;
  CkTar_put_DebugLogFilePath: TCkTar_put_DebugLogFilePath = nil;
  CkTar_get_VerboseLogging: TCkTar_get_VerboseLogging = nil;
  CkTar_put_VerboseLogging: TCkTar_put_VerboseLogging = nil;
  CkTar_get_LastMethodSuccess: TCkTar_get_LastMethodSuccess = nil;
  CkTar_put_LastMethodSuccess: TCkTar_put_LastMethodSuccess = nil;
  CkTar_get_CaptureXmlListing: TCkTar_get_CaptureXmlListing = nil;
  CkTar_put_CaptureXmlListing: TCkTar_put_CaptureXmlListing = nil;
  CkTar_get_Charset: TCkTar_get_Charset = nil;
  CkTar_put_Charset: TCkTar_put_Charset = nil;
  CkTar_get_DirMode: TCkTar_get_DirMode = nil;
  CkTar_put_DirMode: TCkTar_put_DirMode = nil;
  CkTar_get_DirPrefix: TCkTar_get_DirPrefix = nil;
  CkTar_put_DirPrefix: TCkTar_put_DirPrefix = nil;
  CkTar_get_FileMode: TCkTar_get_FileMode = nil;
  CkTar_put_FileMode: TCkTar_put_FileMode = nil;
  CkTar_get_GroupId: TCkTar_get_GroupId = nil;
  CkTar_put_GroupId: TCkTar_put_GroupId = nil;
  CkTar_get_GroupName: TCkTar_get_GroupName = nil;
  CkTar_put_GroupName: TCkTar_put_GroupName = nil;
  CkTar_get_HeartbeatMs: TCkTar_get_HeartbeatMs = nil;
  CkTar_put_HeartbeatMs: TCkTar_put_HeartbeatMs = nil;
  CkTar_get_MatchCaseSensitive: TCkTar_get_MatchCaseSensitive = nil;
  CkTar_put_MatchCaseSensitive: TCkTar_put_MatchCaseSensitive = nil;
  CkTar_get_MustMatch: TCkTar_get_MustMatch = nil;
  CkTar_put_MustMatch: TCkTar_put_MustMatch = nil;
  CkTar_get_MustNotMatch: TCkTar_get_MustNotMatch = nil;
  CkTar_put_MustNotMatch: TCkTar_put_MustNotMatch = nil;
  CkTar_get_NoAbsolutePaths: TCkTar_get_NoAbsolutePaths = nil;
  CkTar_put_NoAbsolutePaths: TCkTar_put_NoAbsolutePaths = nil;
  CkTar_get_NumDirRoots: TCkTar_get_NumDirRoots = nil;
  CkTar_get_PercentDoneScale: TCkTar_get_PercentDoneScale = nil;
  CkTar_put_PercentDoneScale: TCkTar_put_PercentDoneScale = nil;
  CkTar_get_ScriptFileMode: TCkTar_get_ScriptFileMode = nil;
  CkTar_put_ScriptFileMode: TCkTar_put_ScriptFileMode = nil;
  CkTar_get_SuppressOutput: TCkTar_get_SuppressOutput = nil;
  CkTar_put_SuppressOutput: TCkTar_put_SuppressOutput = nil;
  CkTar_get_UntarCaseSensitive: TCkTar_get_UntarCaseSensitive = nil;
  CkTar_put_UntarCaseSensitive: TCkTar_put_UntarCaseSensitive = nil;
  CkTar_get_UntarDebugLog: TCkTar_get_UntarDebugLog = nil;
  CkTar_put_UntarDebugLog: TCkTar_put_UntarDebugLog = nil;
  CkTar_get_UntarDiscardPaths: TCkTar_get_UntarDiscardPaths = nil;
  CkTar_put_UntarDiscardPaths: TCkTar_put_UntarDiscardPaths = nil;
  CkTar_get_UntarFromDir: TCkTar_get_UntarFromDir = nil;
  CkTar_put_UntarFromDir: TCkTar_put_UntarFromDir = nil;
  CkTar_get_UntarMaxCount: TCkTar_get_UntarMaxCount = nil;
  CkTar_put_UntarMaxCount: TCkTar_put_UntarMaxCount = nil;
  CkTar_get_UserId: TCkTar_get_UserId = nil;
  CkTar_put_UserId: TCkTar_put_UserId = nil;
  CkTar_get_UserName: TCkTar_get_UserName = nil;
  CkTar_put_UserName: TCkTar_put_UserName = nil;
  CkTar_get_WriteFormat: TCkTar_get_WriteFormat = nil;
  CkTar_put_WriteFormat: TCkTar_put_WriteFormat = nil;
  CkTar_get_XmlListing: TCkTar_get_XmlListing = nil;
  CkTar_put_XmlListing: TCkTar_put_XmlListing = nil;
  CkTar_AddDirRoot: TCkTar_AddDirRoot = nil;
  CkTar_AddFile: TCkTar_AddFile = nil;
  CkTar_GetDirRoot: TCkTar_GetDirRoot = nil;
  CkTar_ListXml: TCkTar_ListXml = nil;
  CkTar_Untar: TCkTar_Untar = nil;
  CkTar_UntarBz2: TCkTar_UntarBz2 = nil;
  CkTar_UntarGz: TCkTar_UntarGz = nil;
  CkTar_UntarZ: TCkTar_UntarZ = nil;
  CkTar_VerifyTar: TCkTar_VerifyTar = nil;
  CkTar_WriteTar: TCkTar_WriteTar = nil;
  CkTar_WriteTarBz2: TCkTar_WriteTarBz2 = nil;
  CkTar_WriteTarGz: TCkTar_WriteTarGz = nil;
  CkTar_AddDirRoot2: TCkTar_AddDirRoot2 = nil;
  CkTar_CreateDeb: TCkTar_CreateDeb = nil;
  CkTar_AddFile2: TCkTar_AddFile2 = nil;
  CkTar_UntarFirstMatchingToBd: TCkTar_UntarFirstMatchingToBd = nil;
  CkTar_ClearDirRootsAndFiles: TCkTar_ClearDirRootsAndFiles = nil;

constructor TTar.Create;
begin
  inherited Create;
  FHandle := CkTar_Create();
end;

destructor TTar.Destroy;
begin
  if FHandle <> nil then
    CkTar_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

{ ---- Event callback thunks ---- }
{ Standalone cdecl functions registered with the C bridge.  The bridge
  passes back the userData pointer, which carries the Pascal object
  instance.  A non-zero return value aborts the running method. }

function TTar_AbortCheckThunk(userData: Pointer): Integer; cdecl;
var
  obj: TTar;
begin
  Result := 0;
  obj := TTar(userData);
  if Assigned(obj) and Assigned(obj.FOnAbortCheck) then
    if obj.FOnAbortCheck(obj) then Result := 1;
end;

function TTar_PercentDoneThunk(pctDone: Integer; userData: Pointer): Integer; cdecl;
var
  obj: TTar;
begin
  Result := 0;
  obj := TTar(userData);
  if Assigned(obj) and Assigned(obj.FOnPercentDone) then
    if obj.FOnPercentDone(obj, pctDone) then Result := 1;
end;

procedure TTar_ProgressInfoThunk(name: PAnsiChar; value: PAnsiChar; userData: Pointer); cdecl;
var
  obj: TTar;
begin
  obj := TTar(userData);
  if Assigned(obj) and Assigned(obj.FOnProgressInfo) then
    obj.FOnProgressInfo(obj, CkToStr(name), CkToStr(value));
end;

procedure TTar.SetOnAbortCheck(AValue: TChilkatAbortCheckEvent);
begin
  FOnAbortCheck := AValue;
  if Assigned(AValue) then
    CkTar_SetAbortCheckCallback(FHandle, @TTar_AbortCheckThunk, Self)
  else
    CkTar_SetAbortCheckCallback(FHandle, nil, nil);
end;

procedure TTar.SetOnPercentDone(AValue: TChilkatPercentDoneEvent);
begin
  FOnPercentDone := AValue;
  if Assigned(AValue) then
    CkTar_SetPercentDoneCallback(FHandle, @TTar_PercentDoneThunk, Self)
  else
    CkTar_SetPercentDoneCallback(FHandle, nil, nil);
end;

procedure TTar.SetOnProgressInfo(AValue: TChilkatProgressInfoEvent);
begin
  FOnProgressInfo := AValue;
  if Assigned(AValue) then
    CkTar_SetProgressInfoCallback(FHandle, @TTar_ProgressInfoThunk, Self)
  else
    CkTar_SetProgressInfoCallback(FHandle, nil, nil);
end;

function TTar.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkTar_get_LastErrorHtml(FHandle));
end;

function TTar.GetLastErrorText: string;
begin
  Result := CkToStr(CkTar_get_LastErrorText(FHandle));
end;

function TTar.GetLastErrorXml: string;
begin
  Result := CkToStr(CkTar_get_LastErrorXml(FHandle));
end;

function TTar.GetVersion: string;
begin
  Result := CkToStr(CkTar_get_Version(FHandle));
end;

function TTar.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkTar_get_DebugLogFilePath(FHandle));
end;

procedure TTar.SetDebugLogFilePath(AValue: string);
begin
  CkTar_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkTar_get_VerboseLogging(FHandle));
end;

procedure TTar.SetVerboseLogging(AValue: Boolean);
begin
  CkTar_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TTar.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkTar_get_LastMethodSuccess(FHandle));
end;

procedure TTar.SetLastMethodSuccess(AValue: Boolean);
begin
  CkTar_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TTar.GetCaptureXmlListing: Boolean;
begin
  Result := Boolean(CkTar_get_CaptureXmlListing(FHandle));
end;

procedure TTar.SetCaptureXmlListing(AValue: Boolean);
begin
  CkTar_put_CaptureXmlListing(FHandle, LongBool(AValue));
end;

function TTar.GetCharset: string;
begin
  Result := CkToStr(CkTar_get_Charset(FHandle));
end;

procedure TTar.SetCharset(AValue: string);
begin
  CkTar_put_Charset(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetDirMode: Integer;
begin
  Result := CkTar_get_DirMode(FHandle);
end;

procedure TTar.SetDirMode(AValue: Integer);
begin
  CkTar_put_DirMode(FHandle, AValue);
end;

function TTar.GetDirPrefix: string;
begin
  Result := CkToStr(CkTar_get_DirPrefix(FHandle));
end;

procedure TTar.SetDirPrefix(AValue: string);
begin
  CkTar_put_DirPrefix(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetFileMode: Integer;
begin
  Result := CkTar_get_FileMode(FHandle);
end;

procedure TTar.SetFileMode(AValue: Integer);
begin
  CkTar_put_FileMode(FHandle, AValue);
end;

function TTar.GetGroupId: Integer;
begin
  Result := CkTar_get_GroupId(FHandle);
end;

procedure TTar.SetGroupId(AValue: Integer);
begin
  CkTar_put_GroupId(FHandle, AValue);
end;

function TTar.GetGroupName: string;
begin
  Result := CkToStr(CkTar_get_GroupName(FHandle));
end;

procedure TTar.SetGroupName(AValue: string);
begin
  CkTar_put_GroupName(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetHeartbeatMs: Integer;
begin
  Result := CkTar_get_HeartbeatMs(FHandle);
end;

procedure TTar.SetHeartbeatMs(AValue: Integer);
begin
  CkTar_put_HeartbeatMs(FHandle, AValue);
end;

function TTar.GetMatchCaseSensitive: Boolean;
begin
  Result := Boolean(CkTar_get_MatchCaseSensitive(FHandle));
end;

procedure TTar.SetMatchCaseSensitive(AValue: Boolean);
begin
  CkTar_put_MatchCaseSensitive(FHandle, LongBool(AValue));
end;

function TTar.GetMustMatch: string;
begin
  Result := CkToStr(CkTar_get_MustMatch(FHandle));
end;

procedure TTar.SetMustMatch(AValue: string);
begin
  CkTar_put_MustMatch(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetMustNotMatch: string;
begin
  Result := CkToStr(CkTar_get_MustNotMatch(FHandle));
end;

procedure TTar.SetMustNotMatch(AValue: string);
begin
  CkTar_put_MustNotMatch(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetNoAbsolutePaths: Boolean;
begin
  Result := Boolean(CkTar_get_NoAbsolutePaths(FHandle));
end;

procedure TTar.SetNoAbsolutePaths(AValue: Boolean);
begin
  CkTar_put_NoAbsolutePaths(FHandle, LongBool(AValue));
end;

function TTar.GetNumDirRoots: Integer;
begin
  Result := CkTar_get_NumDirRoots(FHandle);
end;

function TTar.GetPercentDoneScale: Integer;
begin
  Result := CkTar_get_PercentDoneScale(FHandle);
end;

procedure TTar.SetPercentDoneScale(AValue: Integer);
begin
  CkTar_put_PercentDoneScale(FHandle, AValue);
end;

function TTar.GetScriptFileMode: Integer;
begin
  Result := CkTar_get_ScriptFileMode(FHandle);
end;

procedure TTar.SetScriptFileMode(AValue: Integer);
begin
  CkTar_put_ScriptFileMode(FHandle, AValue);
end;

function TTar.GetSuppressOutput: Boolean;
begin
  Result := Boolean(CkTar_get_SuppressOutput(FHandle));
end;

procedure TTar.SetSuppressOutput(AValue: Boolean);
begin
  CkTar_put_SuppressOutput(FHandle, LongBool(AValue));
end;

function TTar.GetUntarCaseSensitive: Boolean;
begin
  Result := Boolean(CkTar_get_UntarCaseSensitive(FHandle));
end;

procedure TTar.SetUntarCaseSensitive(AValue: Boolean);
begin
  CkTar_put_UntarCaseSensitive(FHandle, LongBool(AValue));
end;

function TTar.GetUntarDebugLog: Boolean;
begin
  Result := Boolean(CkTar_get_UntarDebugLog(FHandle));
end;

procedure TTar.SetUntarDebugLog(AValue: Boolean);
begin
  CkTar_put_UntarDebugLog(FHandle, LongBool(AValue));
end;

function TTar.GetUntarDiscardPaths: Boolean;
begin
  Result := Boolean(CkTar_get_UntarDiscardPaths(FHandle));
end;

procedure TTar.SetUntarDiscardPaths(AValue: Boolean);
begin
  CkTar_put_UntarDiscardPaths(FHandle, LongBool(AValue));
end;

function TTar.GetUntarFromDir: string;
begin
  Result := CkToStr(CkTar_get_UntarFromDir(FHandle));
end;

procedure TTar.SetUntarFromDir(AValue: string);
begin
  CkTar_put_UntarFromDir(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetUntarMaxCount: Integer;
begin
  Result := CkTar_get_UntarMaxCount(FHandle);
end;

procedure TTar.SetUntarMaxCount(AValue: Integer);
begin
  CkTar_put_UntarMaxCount(FHandle, AValue);
end;

function TTar.GetUserId: Integer;
begin
  Result := CkTar_get_UserId(FHandle);
end;

procedure TTar.SetUserId(AValue: Integer);
begin
  CkTar_put_UserId(FHandle, AValue);
end;

function TTar.GetUserName: string;
begin
  Result := CkToStr(CkTar_get_UserName(FHandle));
end;

procedure TTar.SetUserName(AValue: string);
begin
  CkTar_put_UserName(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetWriteFormat: string;
begin
  Result := CkToStr(CkTar_get_WriteFormat(FHandle));
end;

procedure TTar.SetWriteFormat(AValue: string);
begin
  CkTar_put_WriteFormat(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.GetXmlListing: string;
begin
  Result := CkToStr(CkTar_get_XmlListing(FHandle));
end;

procedure TTar.SetXmlListing(AValue: string);
begin
  CkTar_put_XmlListing(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TTar.AddDirRoot(const dirPath: string): Boolean;
begin
  Result := Boolean(CkTar_AddDirRoot(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

function TTar.AddFile(const path: string): Boolean;
begin
  Result := Boolean(CkTar_AddFile(FHandle, PAnsiChar(StrToCk(path))));
end;

function TTar.GetDirRoot(index: Integer): string;
begin
  Result := CkToStr(CkTar_GetDirRoot(FHandle, index));
end;

function TTar.ListXml(const tarPath: string): string;
begin
  Result := CkToStr(CkTar_ListXml(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.Untar(const tarPath: string): Integer;
begin
  Result := CkTar_Untar(FHandle, PAnsiChar(StrToCk(tarPath)));
end;

function TTar.UntarBz2(const tarPath: string): Boolean;
begin
  Result := Boolean(CkTar_UntarBz2(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.UntarGz(const tarPath: string): Boolean;
begin
  Result := Boolean(CkTar_UntarGz(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.UntarZ(const tarPath: string): Boolean;
begin
  Result := Boolean(CkTar_UntarZ(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.VerifyTar(const tarPath: string): Boolean;
begin
  Result := Boolean(CkTar_VerifyTar(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.WriteTar(const tarPath: string): Boolean;
begin
  Result := Boolean(CkTar_WriteTar(FHandle, PAnsiChar(StrToCk(tarPath))));
end;

function TTar.WriteTarBz2(const bz2Path: string): Boolean;
begin
  Result := Boolean(CkTar_WriteTarBz2(FHandle, PAnsiChar(StrToCk(bz2Path))));
end;

function TTar.WriteTarGz(const gzPath: string): Boolean;
begin
  Result := Boolean(CkTar_WriteTarGz(FHandle, PAnsiChar(StrToCk(gzPath))));
end;

function TTar.AddDirRoot2(const rootPrefix: string; const rootPath: string): Boolean;
begin
  Result := Boolean(CkTar_AddDirRoot2(FHandle, PAnsiChar(StrToCk(rootPrefix)), PAnsiChar(StrToCk(rootPath))));
end;

function TTar.CreateDeb(const controlPath: string; const dataPath: string; const debPath: string): Boolean;
begin
  Result := Boolean(CkTar_CreateDeb(FHandle, PAnsiChar(StrToCk(controlPath)), PAnsiChar(StrToCk(dataPath)), PAnsiChar(StrToCk(debPath))));
end;

function TTar.AddFile2(const filePath: string; const pathWithinTar: string): Boolean;
begin
  Result := Boolean(CkTar_AddFile2(FHandle, PAnsiChar(StrToCk(filePath)), PAnsiChar(StrToCk(pathWithinTar))));
end;

function TTar.UntarFirstMatchingToBd(const tarPath: string; const matchPattern: string; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkTar_UntarFirstMatchingToBd(FHandle, PAnsiChar(StrToCk(tarPath)), PAnsiChar(StrToCk(matchPattern)), bd.Handle));
end;

function TTar.ClearDirRootsAndFiles: Boolean;
begin
  Result := Boolean(CkTar_ClearDirRootsAndFiles(FHandle));
end;

initialization
  Chilkat_GetProcedureAddress(CkTar_Create,  'CkTar_Create');
  Chilkat_GetProcedureAddress(CkTar_Dispose, 'CkTar_Dispose');
  Chilkat_GetProcedureAddress(CkTar_SetAbortCheckCallback, 'CkTar_SetAbortCheckCallback');
  Chilkat_GetProcedureAddress(CkTar_SetPercentDoneCallback, 'CkTar_SetPercentDoneCallback');
  Chilkat_GetProcedureAddress(CkTar_SetProgressInfoCallback, 'CkTar_SetProgressInfoCallback');
  Chilkat_GetProcedureAddress(CkTar_get_LastErrorHtml, 'CkTar_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkTar_get_LastErrorText, 'CkTar_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkTar_get_LastErrorXml, 'CkTar_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkTar_get_Version, 'CkTar_get_Version');
  Chilkat_GetProcedureAddress(CkTar_get_DebugLogFilePath, 'CkTar_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkTar_put_DebugLogFilePath, 'CkTar_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkTar_get_VerboseLogging, 'CkTar_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkTar_put_VerboseLogging, 'CkTar_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkTar_get_LastMethodSuccess, 'CkTar_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkTar_put_LastMethodSuccess, 'CkTar_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkTar_get_CaptureXmlListing, 'CkTar_get_CaptureXmlListing');
  Chilkat_GetProcedureAddress(CkTar_put_CaptureXmlListing, 'CkTar_put_CaptureXmlListing');
  Chilkat_GetProcedureAddress(CkTar_get_Charset, 'CkTar_get_Charset');
  Chilkat_GetProcedureAddress(CkTar_put_Charset, 'CkTar_put_Charset');
  Chilkat_GetProcedureAddress(CkTar_get_DirMode, 'CkTar_get_DirMode');
  Chilkat_GetProcedureAddress(CkTar_put_DirMode, 'CkTar_put_DirMode');
  Chilkat_GetProcedureAddress(CkTar_get_DirPrefix, 'CkTar_get_DirPrefix');
  Chilkat_GetProcedureAddress(CkTar_put_DirPrefix, 'CkTar_put_DirPrefix');
  Chilkat_GetProcedureAddress(CkTar_get_FileMode, 'CkTar_get_FileMode');
  Chilkat_GetProcedureAddress(CkTar_put_FileMode, 'CkTar_put_FileMode');
  Chilkat_GetProcedureAddress(CkTar_get_GroupId, 'CkTar_get_GroupId');
  Chilkat_GetProcedureAddress(CkTar_put_GroupId, 'CkTar_put_GroupId');
  Chilkat_GetProcedureAddress(CkTar_get_GroupName, 'CkTar_get_GroupName');
  Chilkat_GetProcedureAddress(CkTar_put_GroupName, 'CkTar_put_GroupName');
  Chilkat_GetProcedureAddress(CkTar_get_HeartbeatMs, 'CkTar_get_HeartbeatMs');
  Chilkat_GetProcedureAddress(CkTar_put_HeartbeatMs, 'CkTar_put_HeartbeatMs');
  Chilkat_GetProcedureAddress(CkTar_get_MatchCaseSensitive, 'CkTar_get_MatchCaseSensitive');
  Chilkat_GetProcedureAddress(CkTar_put_MatchCaseSensitive, 'CkTar_put_MatchCaseSensitive');
  Chilkat_GetProcedureAddress(CkTar_get_MustMatch, 'CkTar_get_MustMatch');
  Chilkat_GetProcedureAddress(CkTar_put_MustMatch, 'CkTar_put_MustMatch');
  Chilkat_GetProcedureAddress(CkTar_get_MustNotMatch, 'CkTar_get_MustNotMatch');
  Chilkat_GetProcedureAddress(CkTar_put_MustNotMatch, 'CkTar_put_MustNotMatch');
  Chilkat_GetProcedureAddress(CkTar_get_NoAbsolutePaths, 'CkTar_get_NoAbsolutePaths');
  Chilkat_GetProcedureAddress(CkTar_put_NoAbsolutePaths, 'CkTar_put_NoAbsolutePaths');
  Chilkat_GetProcedureAddress(CkTar_get_NumDirRoots, 'CkTar_get_NumDirRoots');
  Chilkat_GetProcedureAddress(CkTar_get_PercentDoneScale, 'CkTar_get_PercentDoneScale');
  Chilkat_GetProcedureAddress(CkTar_put_PercentDoneScale, 'CkTar_put_PercentDoneScale');
  Chilkat_GetProcedureAddress(CkTar_get_ScriptFileMode, 'CkTar_get_ScriptFileMode');
  Chilkat_GetProcedureAddress(CkTar_put_ScriptFileMode, 'CkTar_put_ScriptFileMode');
  Chilkat_GetProcedureAddress(CkTar_get_SuppressOutput, 'CkTar_get_SuppressOutput');
  Chilkat_GetProcedureAddress(CkTar_put_SuppressOutput, 'CkTar_put_SuppressOutput');
  Chilkat_GetProcedureAddress(CkTar_get_UntarCaseSensitive, 'CkTar_get_UntarCaseSensitive');
  Chilkat_GetProcedureAddress(CkTar_put_UntarCaseSensitive, 'CkTar_put_UntarCaseSensitive');
  Chilkat_GetProcedureAddress(CkTar_get_UntarDebugLog, 'CkTar_get_UntarDebugLog');
  Chilkat_GetProcedureAddress(CkTar_put_UntarDebugLog, 'CkTar_put_UntarDebugLog');
  Chilkat_GetProcedureAddress(CkTar_get_UntarDiscardPaths, 'CkTar_get_UntarDiscardPaths');
  Chilkat_GetProcedureAddress(CkTar_put_UntarDiscardPaths, 'CkTar_put_UntarDiscardPaths');
  Chilkat_GetProcedureAddress(CkTar_get_UntarFromDir, 'CkTar_get_UntarFromDir');
  Chilkat_GetProcedureAddress(CkTar_put_UntarFromDir, 'CkTar_put_UntarFromDir');
  Chilkat_GetProcedureAddress(CkTar_get_UntarMaxCount, 'CkTar_get_UntarMaxCount');
  Chilkat_GetProcedureAddress(CkTar_put_UntarMaxCount, 'CkTar_put_UntarMaxCount');
  Chilkat_GetProcedureAddress(CkTar_get_UserId, 'CkTar_get_UserId');
  Chilkat_GetProcedureAddress(CkTar_put_UserId, 'CkTar_put_UserId');
  Chilkat_GetProcedureAddress(CkTar_get_UserName, 'CkTar_get_UserName');
  Chilkat_GetProcedureAddress(CkTar_put_UserName, 'CkTar_put_UserName');
  Chilkat_GetProcedureAddress(CkTar_get_WriteFormat, 'CkTar_get_WriteFormat');
  Chilkat_GetProcedureAddress(CkTar_put_WriteFormat, 'CkTar_put_WriteFormat');
  Chilkat_GetProcedureAddress(CkTar_get_XmlListing, 'CkTar_get_XmlListing');
  Chilkat_GetProcedureAddress(CkTar_put_XmlListing, 'CkTar_put_XmlListing');
  Chilkat_GetProcedureAddress(CkTar_AddDirRoot, 'CkTar_AddDirRoot');
  Chilkat_GetProcedureAddress(CkTar_AddFile, 'CkTar_AddFile');
  Chilkat_GetProcedureAddress(CkTar_GetDirRoot, 'CkTar_GetDirRoot');
  Chilkat_GetProcedureAddress(CkTar_ListXml, 'CkTar_ListXml');
  Chilkat_GetProcedureAddress(CkTar_Untar, 'CkTar_Untar');
  Chilkat_GetProcedureAddress(CkTar_UntarBz2, 'CkTar_UntarBz2');
  Chilkat_GetProcedureAddress(CkTar_UntarGz, 'CkTar_UntarGz');
  Chilkat_GetProcedureAddress(CkTar_UntarZ, 'CkTar_UntarZ');
  Chilkat_GetProcedureAddress(CkTar_VerifyTar, 'CkTar_VerifyTar');
  Chilkat_GetProcedureAddress(CkTar_WriteTar, 'CkTar_WriteTar');
  Chilkat_GetProcedureAddress(CkTar_WriteTarBz2, 'CkTar_WriteTarBz2');
  Chilkat_GetProcedureAddress(CkTar_WriteTarGz, 'CkTar_WriteTarGz');
  Chilkat_GetProcedureAddress(CkTar_AddDirRoot2, 'CkTar_AddDirRoot2');
  Chilkat_GetProcedureAddress(CkTar_CreateDeb, 'CkTar_CreateDeb');
  Chilkat_GetProcedureAddress(CkTar_AddFile2, 'CkTar_AddFile2');
  Chilkat_GetProcedureAddress(CkTar_UntarFirstMatchingToBd, 'CkTar_UntarFirstMatchingToBd');
  Chilkat_GetProcedureAddress(CkTar_ClearDirRootsAndFiles, 'CkTar_ClearDirRootsAndFiles');

end.
