unit Chilkat.FileAccess;

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

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

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TFileAccess wraps CkFileAccess via the C bridge layer. }
  TFileAccess = class(TChilkatBase)
  private
    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  GetCurrentDir: string;
    function  GetEndOfFile: Boolean;
    function  GetFileOpenError: Integer;
    function  GetFileOpenErrorMsg: string;
    function  GetLockFileOnOpen: Boolean;
    procedure SetLockFileOnOpen(AValue: Boolean);
  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 CurrentDir: string read GetCurrentDir;
    property EndOfFile: Boolean read GetEndOfFile;
    property FileOpenError: Integer read GetFileOpenError;
    property FileOpenErrorMsg: string read GetFileOpenErrorMsg;
    property LockFileOnOpen: Boolean read GetLockFileOnOpen write SetLockFileOnOpen;

    function  AppendAnsi(const text: string): Boolean;
    function  AppendText(const str: string; const charset: string): Boolean;
    function  AppendUnicodeBOM: Boolean;
    function  AppendUtf8BOM: Boolean;
    function  DirAutoCreate(const filePath: string): Boolean;
    function  DirCreate(const dirPath: string): Boolean;
    function  DirDelete(const dirPath: string): Boolean;
    function  DirEnsureExists(const dirPath: string): Boolean;
    procedure FileClose;
    function  FileContentsEqual(const filePath1: string; const filePath2: string): Boolean;
    function  FileCopy(const existingFilepath: string; const newFilepath: string; failIfExists: Boolean): Boolean;
    function  FileDelete(const filePath: string): Boolean;
    function  FileExists(const filePath: string): Boolean;
    function  FileExists3(const path: string): Integer;
    function  FileOpen(const filePath: string; accessMode: LongWord; shareMode: LongWord; createDisposition: LongWord; attributes: LongWord): Boolean;
    function  FileRename(const existingFilepath: string; const newFilepath: string): Boolean;
    function  FileSeek(offset: Integer; origin: Integer): Boolean;
    function  FileSize(const filePath: string): Integer;
    function  GenBlockId(index: Integer; length: Integer; const encoding: string): string;
    function  GetNumBlocks(blockSize: Integer): Integer;
    function  GetTempFilename(const dirPath: string; const prefix: string): string;
    function  OpenForAppend(const filePath: string): Boolean;
    function  OpenForRead(const filePath: string): Boolean;
    function  OpenForReadWrite(const filePath: string): Boolean;
    function  OpenForWrite(const filePath: string): Boolean;
    function  ReadBinaryToEncoded(const filePath: string; const encoding: string): string;
    function  ReadEntireTextFile(const filePath: string; const charset: string): string;
    function  ReassembleFile(const partsDirPath: string; const partPrefix: string; const partExtension: string; const reassembledFilename: string): Boolean;
    function  ReplaceStrings(const filePath: string; const charset: string; const existingString: string; const replacementString: string): Integer;
    function  SetCurrentDir(const dirPath: string): Boolean;
    function  SetFileTimes(const filePath: string; createTime: TChilkatBase; lastAccessTime: TChilkatBase; lastModTime: TChilkatBase): Boolean;
    function  SetLastModified(const filePath: string; lastModified: TChilkatBase): Boolean;
    function  SplitFile(const fileToSplit: string; const partPrefix: string; const partExtension: string; partSize: Integer; const destDir: string): Boolean;
    function  TreeDelete(const path: string): Boolean;
    function  WriteEntireTextFile(const filePath: string; const textData: string; const charset: string; includedPreamble: Boolean): Boolean;
    function  FileReadBd(maxNumBytes: Integer; binData: TChilkatBase): Boolean;
    function  FileWriteBd(binData: TChilkatBase; offset: Integer; numBytes: Integer): Boolean;
    function  GetFileName(const path: string): string;
    function  GetDirectoryName(const path: string): string;
    function  GetExtension(const path: string): string;
    function  GetFileNameWithoutExtension(const path: string): string;
    function  AppendSb(sb: TChilkatBase; const charset: string): Boolean;
    function  AppendBd(bd: TChilkatBase): Boolean;
    function  FileType(const path: string): Integer;
    function  SymlinkTarget(const linkPath: string): string;
    function  SymlinkCreate(const targetPath: string; const linkPath: string): Boolean;
    function  ReadBlockBd(blockIndex: Integer; blockSize: Integer; bd: TChilkatBase): Boolean;
    function  FileSizeStr(const filePath: string): string;
    function  ReadNextFragment(startAtBeginning: Boolean; const beginMarker: string; const endMarker: string; const charset: string; sb: TChilkatBase): Integer;
    function  Truncate: Boolean;
    function  FileWrite2(pByteData: Pointer; szByteData: LongWord): Boolean;
    function  FileSize64(const filePath: string): Int64;
    function  DirExists(const dirPath: string): Boolean;
    function  GetFileTimeStr(const path: string; which: Integer): string;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkFileAccess_Create  = function(): Pointer; cdecl;
  TCkFileAccess_Dispose = procedure(handle: Pointer); cdecl;
  TCkFileAccess_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkFileAccess_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkFileAccess_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkFileAccess_get_CurrentDir = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_EndOfFile = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_get_FileOpenError = function(handle: Pointer): Integer; cdecl;
  TCkFileAccess_get_FileOpenErrorMsg = function(handle: Pointer): PAnsiChar; cdecl;
  TCkFileAccess_get_LockFileOnOpen = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_put_LockFileOnOpen = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkFileAccess_AppendAnsi = function(handle: Pointer; text: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_AppendText = function(handle: Pointer; str: PAnsiChar; charset: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_AppendUnicodeBOM = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_AppendUtf8BOM = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_DirAutoCreate = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_DirCreate = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_DirDelete = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_DirEnsureExists = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_FileClose = procedure(handle: Pointer); cdecl;
  TCkFileAccess_FileContentsEqual = function(handle: Pointer; filePath1: PAnsiChar; filePath2: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_FileCopy = function(handle: Pointer; existingFilepath: PAnsiChar; newFilepath: PAnsiChar; failIfExists: LongBool): LongBool; cdecl;
  TCkFileAccess_FileDelete = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_FileExists = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_FileExists3 = function(handle: Pointer; path: PAnsiChar): Integer; cdecl;
  TCkFileAccess_FileOpen = function(handle: Pointer; filePath: PAnsiChar; accessMode: LongWord; shareMode: LongWord; createDisposition: LongWord; attributes: LongWord): LongBool; cdecl;
  TCkFileAccess_FileRename = function(handle: Pointer; existingFilepath: PAnsiChar; newFilepath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_FileSeek = function(handle: Pointer; offset: Integer; origin: Integer): LongBool; cdecl;
  TCkFileAccess_FileSize = function(handle: Pointer; filePath: PAnsiChar): Integer; cdecl;
  TCkFileAccess_GenBlockId = function(handle: Pointer; index: Integer; length: Integer; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_GetNumBlocks = function(handle: Pointer; blockSize: Integer): Integer; cdecl;
  TCkFileAccess_GetTempFilename = function(handle: Pointer; dirPath: PAnsiChar; prefix: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_OpenForAppend = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_OpenForRead = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_OpenForReadWrite = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_OpenForWrite = function(handle: Pointer; filePath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_ReadBinaryToEncoded = function(handle: Pointer; filePath: PAnsiChar; encoding: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_ReadEntireTextFile = function(handle: Pointer; filePath: PAnsiChar; charset: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_ReassembleFile = function(handle: Pointer; partsDirPath: PAnsiChar; partPrefix: PAnsiChar; partExtension: PAnsiChar; reassembledFilename: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_ReplaceStrings = function(handle: Pointer; filePath: PAnsiChar; charset: PAnsiChar; existingString: PAnsiChar; replacementString: PAnsiChar): Integer; cdecl;
  TCkFileAccess_SetCurrentDir = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_SetFileTimes = function(handle: Pointer; filePath: PAnsiChar; createTime: Pointer; lastAccessTime: Pointer; lastModTime: Pointer): LongBool; cdecl;
  TCkFileAccess_SetLastModified = function(handle: Pointer; filePath: PAnsiChar; lastModified: Pointer): LongBool; cdecl;
  TCkFileAccess_SplitFile = function(handle: Pointer; fileToSplit: PAnsiChar; partPrefix: PAnsiChar; partExtension: PAnsiChar; partSize: Integer; destDir: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_TreeDelete = function(handle: Pointer; path: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_WriteEntireTextFile = function(handle: Pointer; filePath: PAnsiChar; textData: PAnsiChar; charset: PAnsiChar; includedPreamble: LongBool): LongBool; cdecl;
  TCkFileAccess_FileReadBd = function(handle: Pointer; maxNumBytes: Integer; binData: Pointer): LongBool; cdecl;
  TCkFileAccess_FileWriteBd = function(handle: Pointer; binData: Pointer; offset: Integer; numBytes: Integer): LongBool; cdecl;
  TCkFileAccess_GetFileName = function(handle: Pointer; path: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_GetDirectoryName = function(handle: Pointer; path: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_GetExtension = function(handle: Pointer; path: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_GetFileNameWithoutExtension = function(handle: Pointer; path: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_AppendSb = function(handle: Pointer; sb: Pointer; charset: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_AppendBd = function(handle: Pointer; bd: Pointer): LongBool; cdecl;
  TCkFileAccess_FileType = function(handle: Pointer; path: PAnsiChar): Integer; cdecl;
  TCkFileAccess_SymlinkTarget = function(handle: Pointer; linkPath: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_SymlinkCreate = function(handle: Pointer; targetPath: PAnsiChar; linkPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_ReadBlockBd = function(handle: Pointer; blockIndex: Integer; blockSize: Integer; bd: Pointer): LongBool; cdecl;
  TCkFileAccess_FileSizeStr = function(handle: Pointer; filePath: PAnsiChar): PAnsiChar; cdecl;
  TCkFileAccess_ReadNextFragment = function(handle: Pointer; startAtBeginning: LongBool; beginMarker: PAnsiChar; endMarker: PAnsiChar; charset: PAnsiChar; sb: Pointer): Integer; cdecl;
  TCkFileAccess_Truncate = function(handle: Pointer): LongBool; cdecl;
  TCkFileAccess_FileWrite2 = function(handle: Pointer; pByteData: Pointer; szByteData: LongWord): LongBool; cdecl;
  TCkFileAccess_FileSize64 = function(handle: Pointer; filePath: PAnsiChar): Int64; cdecl;
  TCkFileAccess_DirExists = function(handle: Pointer; dirPath: PAnsiChar): LongBool; cdecl;
  TCkFileAccess_GetFileTimeStr = function(handle: Pointer; path: PAnsiChar; which: Integer): PAnsiChar; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkFileAccess_Create:  TCkFileAccess_Create  = nil;
  CkFileAccess_Dispose: TCkFileAccess_Dispose = nil;
  CkFileAccess_get_LastErrorHtml: TCkFileAccess_get_LastErrorHtml = nil;
  CkFileAccess_get_LastErrorText: TCkFileAccess_get_LastErrorText = nil;
  CkFileAccess_get_LastErrorXml: TCkFileAccess_get_LastErrorXml = nil;
  CkFileAccess_get_Version: TCkFileAccess_get_Version = nil;
  CkFileAccess_get_DebugLogFilePath: TCkFileAccess_get_DebugLogFilePath = nil;
  CkFileAccess_put_DebugLogFilePath: TCkFileAccess_put_DebugLogFilePath = nil;
  CkFileAccess_get_VerboseLogging: TCkFileAccess_get_VerboseLogging = nil;
  CkFileAccess_put_VerboseLogging: TCkFileAccess_put_VerboseLogging = nil;
  CkFileAccess_get_LastMethodSuccess: TCkFileAccess_get_LastMethodSuccess = nil;
  CkFileAccess_put_LastMethodSuccess: TCkFileAccess_put_LastMethodSuccess = nil;
  CkFileAccess_get_CurrentDir: TCkFileAccess_get_CurrentDir = nil;
  CkFileAccess_get_EndOfFile: TCkFileAccess_get_EndOfFile = nil;
  CkFileAccess_get_FileOpenError: TCkFileAccess_get_FileOpenError = nil;
  CkFileAccess_get_FileOpenErrorMsg: TCkFileAccess_get_FileOpenErrorMsg = nil;
  CkFileAccess_get_LockFileOnOpen: TCkFileAccess_get_LockFileOnOpen = nil;
  CkFileAccess_put_LockFileOnOpen: TCkFileAccess_put_LockFileOnOpen = nil;
  CkFileAccess_AppendAnsi: TCkFileAccess_AppendAnsi = nil;
  CkFileAccess_AppendText: TCkFileAccess_AppendText = nil;
  CkFileAccess_AppendUnicodeBOM: TCkFileAccess_AppendUnicodeBOM = nil;
  CkFileAccess_AppendUtf8BOM: TCkFileAccess_AppendUtf8BOM = nil;
  CkFileAccess_DirAutoCreate: TCkFileAccess_DirAutoCreate = nil;
  CkFileAccess_DirCreate: TCkFileAccess_DirCreate = nil;
  CkFileAccess_DirDelete: TCkFileAccess_DirDelete = nil;
  CkFileAccess_DirEnsureExists: TCkFileAccess_DirEnsureExists = nil;
  CkFileAccess_FileClose: TCkFileAccess_FileClose = nil;
  CkFileAccess_FileContentsEqual: TCkFileAccess_FileContentsEqual = nil;
  CkFileAccess_FileCopy: TCkFileAccess_FileCopy = nil;
  CkFileAccess_FileDelete: TCkFileAccess_FileDelete = nil;
  CkFileAccess_FileExists: TCkFileAccess_FileExists = nil;
  CkFileAccess_FileExists3: TCkFileAccess_FileExists3 = nil;
  CkFileAccess_FileOpen: TCkFileAccess_FileOpen = nil;
  CkFileAccess_FileRename: TCkFileAccess_FileRename = nil;
  CkFileAccess_FileSeek: TCkFileAccess_FileSeek = nil;
  CkFileAccess_FileSize: TCkFileAccess_FileSize = nil;
  CkFileAccess_GenBlockId: TCkFileAccess_GenBlockId = nil;
  CkFileAccess_GetNumBlocks: TCkFileAccess_GetNumBlocks = nil;
  CkFileAccess_GetTempFilename: TCkFileAccess_GetTempFilename = nil;
  CkFileAccess_OpenForAppend: TCkFileAccess_OpenForAppend = nil;
  CkFileAccess_OpenForRead: TCkFileAccess_OpenForRead = nil;
  CkFileAccess_OpenForReadWrite: TCkFileAccess_OpenForReadWrite = nil;
  CkFileAccess_OpenForWrite: TCkFileAccess_OpenForWrite = nil;
  CkFileAccess_ReadBinaryToEncoded: TCkFileAccess_ReadBinaryToEncoded = nil;
  CkFileAccess_ReadEntireTextFile: TCkFileAccess_ReadEntireTextFile = nil;
  CkFileAccess_ReassembleFile: TCkFileAccess_ReassembleFile = nil;
  CkFileAccess_ReplaceStrings: TCkFileAccess_ReplaceStrings = nil;
  CkFileAccess_SetCurrentDir: TCkFileAccess_SetCurrentDir = nil;
  CkFileAccess_SetFileTimes: TCkFileAccess_SetFileTimes = nil;
  CkFileAccess_SetLastModified: TCkFileAccess_SetLastModified = nil;
  CkFileAccess_SplitFile: TCkFileAccess_SplitFile = nil;
  CkFileAccess_TreeDelete: TCkFileAccess_TreeDelete = nil;
  CkFileAccess_WriteEntireTextFile: TCkFileAccess_WriteEntireTextFile = nil;
  CkFileAccess_FileReadBd: TCkFileAccess_FileReadBd = nil;
  CkFileAccess_FileWriteBd: TCkFileAccess_FileWriteBd = nil;
  CkFileAccess_GetFileName: TCkFileAccess_GetFileName = nil;
  CkFileAccess_GetDirectoryName: TCkFileAccess_GetDirectoryName = nil;
  CkFileAccess_GetExtension: TCkFileAccess_GetExtension = nil;
  CkFileAccess_GetFileNameWithoutExtension: TCkFileAccess_GetFileNameWithoutExtension = nil;
  CkFileAccess_AppendSb: TCkFileAccess_AppendSb = nil;
  CkFileAccess_AppendBd: TCkFileAccess_AppendBd = nil;
  CkFileAccess_FileType: TCkFileAccess_FileType = nil;
  CkFileAccess_SymlinkTarget: TCkFileAccess_SymlinkTarget = nil;
  CkFileAccess_SymlinkCreate: TCkFileAccess_SymlinkCreate = nil;
  CkFileAccess_ReadBlockBd: TCkFileAccess_ReadBlockBd = nil;
  CkFileAccess_FileSizeStr: TCkFileAccess_FileSizeStr = nil;
  CkFileAccess_ReadNextFragment: TCkFileAccess_ReadNextFragment = nil;
  CkFileAccess_Truncate: TCkFileAccess_Truncate = nil;
  CkFileAccess_FileWrite2: TCkFileAccess_FileWrite2 = nil;
  CkFileAccess_FileSize64: TCkFileAccess_FileSize64 = nil;
  CkFileAccess_DirExists: TCkFileAccess_DirExists = nil;
  CkFileAccess_GetFileTimeStr: TCkFileAccess_GetFileTimeStr = nil;

constructor TFileAccess.Create;
begin
  inherited Create;
  FHandle := CkFileAccess_Create();
end;

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

function TFileAccess.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkFileAccess_get_LastErrorHtml(FHandle));
end;

function TFileAccess.GetLastErrorText: string;
begin
  Result := CkToStr(CkFileAccess_get_LastErrorText(FHandle));
end;

function TFileAccess.GetLastErrorXml: string;
begin
  Result := CkToStr(CkFileAccess_get_LastErrorXml(FHandle));
end;

function TFileAccess.GetVersion: string;
begin
  Result := CkToStr(CkFileAccess_get_Version(FHandle));
end;

function TFileAccess.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkFileAccess_get_DebugLogFilePath(FHandle));
end;

procedure TFileAccess.SetDebugLogFilePath(AValue: string);
begin
  CkFileAccess_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TFileAccess.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkFileAccess_get_VerboseLogging(FHandle));
end;

procedure TFileAccess.SetVerboseLogging(AValue: Boolean);
begin
  CkFileAccess_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TFileAccess.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkFileAccess_get_LastMethodSuccess(FHandle));
end;

procedure TFileAccess.SetLastMethodSuccess(AValue: Boolean);
begin
  CkFileAccess_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TFileAccess.GetCurrentDir: string;
begin
  Result := CkToStr(CkFileAccess_get_CurrentDir(FHandle));
end;

function TFileAccess.GetEndOfFile: Boolean;
begin
  Result := Boolean(CkFileAccess_get_EndOfFile(FHandle));
end;

function TFileAccess.GetFileOpenError: Integer;
begin
  Result := CkFileAccess_get_FileOpenError(FHandle);
end;

function TFileAccess.GetFileOpenErrorMsg: string;
begin
  Result := CkToStr(CkFileAccess_get_FileOpenErrorMsg(FHandle));
end;

function TFileAccess.GetLockFileOnOpen: Boolean;
begin
  Result := Boolean(CkFileAccess_get_LockFileOnOpen(FHandle));
end;

procedure TFileAccess.SetLockFileOnOpen(AValue: Boolean);
begin
  CkFileAccess_put_LockFileOnOpen(FHandle, LongBool(AValue));
end;

function TFileAccess.AppendAnsi(const text: string): Boolean;
begin
  Result := Boolean(CkFileAccess_AppendAnsi(FHandle, PAnsiChar(StrToCk(text))));
end;

function TFileAccess.AppendText(const str: string; const charset: string): Boolean;
begin
  Result := Boolean(CkFileAccess_AppendText(FHandle, PAnsiChar(StrToCk(str)), PAnsiChar(StrToCk(charset))));
end;

function TFileAccess.AppendUnicodeBOM: Boolean;
begin
  Result := Boolean(CkFileAccess_AppendUnicodeBOM(FHandle));
end;

function TFileAccess.AppendUtf8BOM: Boolean;
begin
  Result := Boolean(CkFileAccess_AppendUtf8BOM(FHandle));
end;

function TFileAccess.DirAutoCreate(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_DirAutoCreate(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.DirCreate(const dirPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_DirCreate(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

function TFileAccess.DirDelete(const dirPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_DirDelete(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

function TFileAccess.DirEnsureExists(const dirPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_DirEnsureExists(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

procedure TFileAccess.FileClose;
begin
  CkFileAccess_FileClose(FHandle);
end;

function TFileAccess.FileContentsEqual(const filePath1: string; const filePath2: string): Boolean;
begin
  Result := Boolean(CkFileAccess_FileContentsEqual(FHandle, PAnsiChar(StrToCk(filePath1)), PAnsiChar(StrToCk(filePath2))));
end;

function TFileAccess.FileCopy(const existingFilepath: string; const newFilepath: string; failIfExists: Boolean): Boolean;
begin
  Result := Boolean(CkFileAccess_FileCopy(FHandle, PAnsiChar(StrToCk(existingFilepath)), PAnsiChar(StrToCk(newFilepath)), LongBool(failIfExists)));
end;

function TFileAccess.FileDelete(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_FileDelete(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.FileExists(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_FileExists(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.FileExists3(const path: string): Integer;
begin
  Result := CkFileAccess_FileExists3(FHandle, PAnsiChar(StrToCk(path)));
end;

function TFileAccess.FileOpen(const filePath: string; accessMode: LongWord; shareMode: LongWord; createDisposition: LongWord; attributes: LongWord): Boolean;
begin
  Result := Boolean(CkFileAccess_FileOpen(FHandle, PAnsiChar(StrToCk(filePath)), accessMode, shareMode, createDisposition, attributes));
end;

function TFileAccess.FileRename(const existingFilepath: string; const newFilepath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_FileRename(FHandle, PAnsiChar(StrToCk(existingFilepath)), PAnsiChar(StrToCk(newFilepath))));
end;

function TFileAccess.FileSeek(offset: Integer; origin: Integer): Boolean;
begin
  Result := Boolean(CkFileAccess_FileSeek(FHandle, offset, origin));
end;

function TFileAccess.FileSize(const filePath: string): Integer;
begin
  Result := CkFileAccess_FileSize(FHandle, PAnsiChar(StrToCk(filePath)));
end;

function TFileAccess.GenBlockId(index: Integer; length: Integer; const encoding: string): string;
begin
  Result := CkToStr(CkFileAccess_GenBlockId(FHandle, index, length, PAnsiChar(StrToCk(encoding))));
end;

function TFileAccess.GetNumBlocks(blockSize: Integer): Integer;
begin
  Result := CkFileAccess_GetNumBlocks(FHandle, blockSize);
end;

function TFileAccess.GetTempFilename(const dirPath: string; const prefix: string): string;
begin
  Result := CkToStr(CkFileAccess_GetTempFilename(FHandle, PAnsiChar(StrToCk(dirPath)), PAnsiChar(StrToCk(prefix))));
end;

function TFileAccess.OpenForAppend(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_OpenForAppend(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.OpenForRead(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_OpenForRead(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.OpenForReadWrite(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_OpenForReadWrite(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.OpenForWrite(const filePath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_OpenForWrite(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.ReadBinaryToEncoded(const filePath: string; const encoding: string): string;
begin
  Result := CkToStr(CkFileAccess_ReadBinaryToEncoded(FHandle, PAnsiChar(StrToCk(filePath)), PAnsiChar(StrToCk(encoding))));
end;

function TFileAccess.ReadEntireTextFile(const filePath: string; const charset: string): string;
begin
  Result := CkToStr(CkFileAccess_ReadEntireTextFile(FHandle, PAnsiChar(StrToCk(filePath)), PAnsiChar(StrToCk(charset))));
end;

function TFileAccess.ReassembleFile(const partsDirPath: string; const partPrefix: string; const partExtension: string; const reassembledFilename: string): Boolean;
begin
  Result := Boolean(CkFileAccess_ReassembleFile(FHandle, PAnsiChar(StrToCk(partsDirPath)), PAnsiChar(StrToCk(partPrefix)), PAnsiChar(StrToCk(partExtension)), PAnsiChar(StrToCk(reassembledFilename))));
end;

function TFileAccess.ReplaceStrings(const filePath: string; const charset: string; const existingString: string; const replacementString: string): Integer;
begin
  Result := CkFileAccess_ReplaceStrings(FHandle, PAnsiChar(StrToCk(filePath)), PAnsiChar(StrToCk(charset)), PAnsiChar(StrToCk(existingString)), PAnsiChar(StrToCk(replacementString)));
end;

function TFileAccess.SetCurrentDir(const dirPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_SetCurrentDir(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

function TFileAccess.SetFileTimes(const filePath: string; createTime: TChilkatBase; lastAccessTime: TChilkatBase; lastModTime: TChilkatBase): Boolean;
begin
  Result := Boolean(CkFileAccess_SetFileTimes(FHandle, PAnsiChar(StrToCk(filePath)), createTime.Handle, lastAccessTime.Handle, lastModTime.Handle));
end;

function TFileAccess.SetLastModified(const filePath: string; lastModified: TChilkatBase): Boolean;
begin
  Result := Boolean(CkFileAccess_SetLastModified(FHandle, PAnsiChar(StrToCk(filePath)), lastModified.Handle));
end;

function TFileAccess.SplitFile(const fileToSplit: string; const partPrefix: string; const partExtension: string; partSize: Integer; const destDir: string): Boolean;
begin
  Result := Boolean(CkFileAccess_SplitFile(FHandle, PAnsiChar(StrToCk(fileToSplit)), PAnsiChar(StrToCk(partPrefix)), PAnsiChar(StrToCk(partExtension)), partSize, PAnsiChar(StrToCk(destDir))));
end;

function TFileAccess.TreeDelete(const path: string): Boolean;
begin
  Result := Boolean(CkFileAccess_TreeDelete(FHandle, PAnsiChar(StrToCk(path))));
end;

function TFileAccess.WriteEntireTextFile(const filePath: string; const textData: string; const charset: string; includedPreamble: Boolean): Boolean;
begin
  Result := Boolean(CkFileAccess_WriteEntireTextFile(FHandle, PAnsiChar(StrToCk(filePath)), PAnsiChar(StrToCk(textData)), PAnsiChar(StrToCk(charset)), LongBool(includedPreamble)));
end;

function TFileAccess.FileReadBd(maxNumBytes: Integer; binData: TChilkatBase): Boolean;
begin
  Result := Boolean(CkFileAccess_FileReadBd(FHandle, maxNumBytes, binData.Handle));
end;

function TFileAccess.FileWriteBd(binData: TChilkatBase; offset: Integer; numBytes: Integer): Boolean;
begin
  Result := Boolean(CkFileAccess_FileWriteBd(FHandle, binData.Handle, offset, numBytes));
end;

function TFileAccess.GetFileName(const path: string): string;
begin
  Result := CkToStr(CkFileAccess_GetFileName(FHandle, PAnsiChar(StrToCk(path))));
end;

function TFileAccess.GetDirectoryName(const path: string): string;
begin
  Result := CkToStr(CkFileAccess_GetDirectoryName(FHandle, PAnsiChar(StrToCk(path))));
end;

function TFileAccess.GetExtension(const path: string): string;
begin
  Result := CkToStr(CkFileAccess_GetExtension(FHandle, PAnsiChar(StrToCk(path))));
end;

function TFileAccess.GetFileNameWithoutExtension(const path: string): string;
begin
  Result := CkToStr(CkFileAccess_GetFileNameWithoutExtension(FHandle, PAnsiChar(StrToCk(path))));
end;

function TFileAccess.AppendSb(sb: TChilkatBase; const charset: string): Boolean;
begin
  Result := Boolean(CkFileAccess_AppendSb(FHandle, sb.Handle, PAnsiChar(StrToCk(charset))));
end;

function TFileAccess.AppendBd(bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkFileAccess_AppendBd(FHandle, bd.Handle));
end;

function TFileAccess.FileType(const path: string): Integer;
begin
  Result := CkFileAccess_FileType(FHandle, PAnsiChar(StrToCk(path)));
end;

function TFileAccess.SymlinkTarget(const linkPath: string): string;
begin
  Result := CkToStr(CkFileAccess_SymlinkTarget(FHandle, PAnsiChar(StrToCk(linkPath))));
end;

function TFileAccess.SymlinkCreate(const targetPath: string; const linkPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_SymlinkCreate(FHandle, PAnsiChar(StrToCk(targetPath)), PAnsiChar(StrToCk(linkPath))));
end;

function TFileAccess.ReadBlockBd(blockIndex: Integer; blockSize: Integer; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkFileAccess_ReadBlockBd(FHandle, blockIndex, blockSize, bd.Handle));
end;

function TFileAccess.FileSizeStr(const filePath: string): string;
begin
  Result := CkToStr(CkFileAccess_FileSizeStr(FHandle, PAnsiChar(StrToCk(filePath))));
end;

function TFileAccess.ReadNextFragment(startAtBeginning: Boolean; const beginMarker: string; const endMarker: string; const charset: string; sb: TChilkatBase): Integer;
begin
  Result := CkFileAccess_ReadNextFragment(FHandle, LongBool(startAtBeginning), PAnsiChar(StrToCk(beginMarker)), PAnsiChar(StrToCk(endMarker)), PAnsiChar(StrToCk(charset)), sb.Handle);
end;

function TFileAccess.Truncate: Boolean;
begin
  Result := Boolean(CkFileAccess_Truncate(FHandle));
end;

function TFileAccess.FileWrite2(pByteData: Pointer; szByteData: LongWord): Boolean;
begin
  Result := Boolean(CkFileAccess_FileWrite2(FHandle, pByteData, szByteData));
end;

function TFileAccess.FileSize64(const filePath: string): Int64;
begin
  Result := CkFileAccess_FileSize64(FHandle, PAnsiChar(StrToCk(filePath)));
end;

function TFileAccess.DirExists(const dirPath: string): Boolean;
begin
  Result := Boolean(CkFileAccess_DirExists(FHandle, PAnsiChar(StrToCk(dirPath))));
end;

function TFileAccess.GetFileTimeStr(const path: string; which: Integer): string;
begin
  Result := CkToStr(CkFileAccess_GetFileTimeStr(FHandle, PAnsiChar(StrToCk(path)), which));
end;

initialization
  Chilkat_GetProcedureAddress(CkFileAccess_Create,  'CkFileAccess_Create');
  Chilkat_GetProcedureAddress(CkFileAccess_Dispose, 'CkFileAccess_Dispose');
  Chilkat_GetProcedureAddress(CkFileAccess_get_LastErrorHtml, 'CkFileAccess_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkFileAccess_get_LastErrorText, 'CkFileAccess_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkFileAccess_get_LastErrorXml, 'CkFileAccess_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkFileAccess_get_Version, 'CkFileAccess_get_Version');
  Chilkat_GetProcedureAddress(CkFileAccess_get_DebugLogFilePath, 'CkFileAccess_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkFileAccess_put_DebugLogFilePath, 'CkFileAccess_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkFileAccess_get_VerboseLogging, 'CkFileAccess_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkFileAccess_put_VerboseLogging, 'CkFileAccess_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkFileAccess_get_LastMethodSuccess, 'CkFileAccess_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkFileAccess_put_LastMethodSuccess, 'CkFileAccess_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkFileAccess_get_CurrentDir, 'CkFileAccess_get_CurrentDir');
  Chilkat_GetProcedureAddress(CkFileAccess_get_EndOfFile, 'CkFileAccess_get_EndOfFile');
  Chilkat_GetProcedureAddress(CkFileAccess_get_FileOpenError, 'CkFileAccess_get_FileOpenError');
  Chilkat_GetProcedureAddress(CkFileAccess_get_FileOpenErrorMsg, 'CkFileAccess_get_FileOpenErrorMsg');
  Chilkat_GetProcedureAddress(CkFileAccess_get_LockFileOnOpen, 'CkFileAccess_get_LockFileOnOpen');
  Chilkat_GetProcedureAddress(CkFileAccess_put_LockFileOnOpen, 'CkFileAccess_put_LockFileOnOpen');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendAnsi, 'CkFileAccess_AppendAnsi');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendText, 'CkFileAccess_AppendText');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendUnicodeBOM, 'CkFileAccess_AppendUnicodeBOM');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendUtf8BOM, 'CkFileAccess_AppendUtf8BOM');
  Chilkat_GetProcedureAddress(CkFileAccess_DirAutoCreate, 'CkFileAccess_DirAutoCreate');
  Chilkat_GetProcedureAddress(CkFileAccess_DirCreate, 'CkFileAccess_DirCreate');
  Chilkat_GetProcedureAddress(CkFileAccess_DirDelete, 'CkFileAccess_DirDelete');
  Chilkat_GetProcedureAddress(CkFileAccess_DirEnsureExists, 'CkFileAccess_DirEnsureExists');
  Chilkat_GetProcedureAddress(CkFileAccess_FileClose, 'CkFileAccess_FileClose');
  Chilkat_GetProcedureAddress(CkFileAccess_FileContentsEqual, 'CkFileAccess_FileContentsEqual');
  Chilkat_GetProcedureAddress(CkFileAccess_FileCopy, 'CkFileAccess_FileCopy');
  Chilkat_GetProcedureAddress(CkFileAccess_FileDelete, 'CkFileAccess_FileDelete');
  Chilkat_GetProcedureAddress(CkFileAccess_FileExists, 'CkFileAccess_FileExists');
  Chilkat_GetProcedureAddress(CkFileAccess_FileExists3, 'CkFileAccess_FileExists3');
  Chilkat_GetProcedureAddress(CkFileAccess_FileOpen, 'CkFileAccess_FileOpen');
  Chilkat_GetProcedureAddress(CkFileAccess_FileRename, 'CkFileAccess_FileRename');
  Chilkat_GetProcedureAddress(CkFileAccess_FileSeek, 'CkFileAccess_FileSeek');
  Chilkat_GetProcedureAddress(CkFileAccess_FileSize, 'CkFileAccess_FileSize');
  Chilkat_GetProcedureAddress(CkFileAccess_GenBlockId, 'CkFileAccess_GenBlockId');
  Chilkat_GetProcedureAddress(CkFileAccess_GetNumBlocks, 'CkFileAccess_GetNumBlocks');
  Chilkat_GetProcedureAddress(CkFileAccess_GetTempFilename, 'CkFileAccess_GetTempFilename');
  Chilkat_GetProcedureAddress(CkFileAccess_OpenForAppend, 'CkFileAccess_OpenForAppend');
  Chilkat_GetProcedureAddress(CkFileAccess_OpenForRead, 'CkFileAccess_OpenForRead');
  Chilkat_GetProcedureAddress(CkFileAccess_OpenForReadWrite, 'CkFileAccess_OpenForReadWrite');
  Chilkat_GetProcedureAddress(CkFileAccess_OpenForWrite, 'CkFileAccess_OpenForWrite');
  Chilkat_GetProcedureAddress(CkFileAccess_ReadBinaryToEncoded, 'CkFileAccess_ReadBinaryToEncoded');
  Chilkat_GetProcedureAddress(CkFileAccess_ReadEntireTextFile, 'CkFileAccess_ReadEntireTextFile');
  Chilkat_GetProcedureAddress(CkFileAccess_ReassembleFile, 'CkFileAccess_ReassembleFile');
  Chilkat_GetProcedureAddress(CkFileAccess_ReplaceStrings, 'CkFileAccess_ReplaceStrings');
  Chilkat_GetProcedureAddress(CkFileAccess_SetCurrentDir, 'CkFileAccess_SetCurrentDir');
  Chilkat_GetProcedureAddress(CkFileAccess_SetFileTimes, 'CkFileAccess_SetFileTimes');
  Chilkat_GetProcedureAddress(CkFileAccess_SetLastModified, 'CkFileAccess_SetLastModified');
  Chilkat_GetProcedureAddress(CkFileAccess_SplitFile, 'CkFileAccess_SplitFile');
  Chilkat_GetProcedureAddress(CkFileAccess_TreeDelete, 'CkFileAccess_TreeDelete');
  Chilkat_GetProcedureAddress(CkFileAccess_WriteEntireTextFile, 'CkFileAccess_WriteEntireTextFile');
  Chilkat_GetProcedureAddress(CkFileAccess_FileReadBd, 'CkFileAccess_FileReadBd');
  Chilkat_GetProcedureAddress(CkFileAccess_FileWriteBd, 'CkFileAccess_FileWriteBd');
  Chilkat_GetProcedureAddress(CkFileAccess_GetFileName, 'CkFileAccess_GetFileName');
  Chilkat_GetProcedureAddress(CkFileAccess_GetDirectoryName, 'CkFileAccess_GetDirectoryName');
  Chilkat_GetProcedureAddress(CkFileAccess_GetExtension, 'CkFileAccess_GetExtension');
  Chilkat_GetProcedureAddress(CkFileAccess_GetFileNameWithoutExtension, 'CkFileAccess_GetFileNameWithoutExtension');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendSb, 'CkFileAccess_AppendSb');
  Chilkat_GetProcedureAddress(CkFileAccess_AppendBd, 'CkFileAccess_AppendBd');
  Chilkat_GetProcedureAddress(CkFileAccess_FileType, 'CkFileAccess_FileType');
  Chilkat_GetProcedureAddress(CkFileAccess_SymlinkTarget, 'CkFileAccess_SymlinkTarget');
  Chilkat_GetProcedureAddress(CkFileAccess_SymlinkCreate, 'CkFileAccess_SymlinkCreate');
  Chilkat_GetProcedureAddress(CkFileAccess_ReadBlockBd, 'CkFileAccess_ReadBlockBd');
  Chilkat_GetProcedureAddress(CkFileAccess_FileSizeStr, 'CkFileAccess_FileSizeStr');
  Chilkat_GetProcedureAddress(CkFileAccess_ReadNextFragment, 'CkFileAccess_ReadNextFragment');
  Chilkat_GetProcedureAddress(CkFileAccess_Truncate, 'CkFileAccess_Truncate');
  Chilkat_GetProcedureAddress(CkFileAccess_FileWrite2, 'CkFileAccess_FileWrite2');
  Chilkat_GetProcedureAddress(CkFileAccess_FileSize64, 'CkFileAccess_FileSize64');
  Chilkat_GetProcedureAddress(CkFileAccess_DirExists, 'CkFileAccess_DirExists');
  Chilkat_GetProcedureAddress(CkFileAccess_GetFileTimeStr, 'CkFileAccess_GetFileTimeStr');

end.
