⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abfcifdi.pas

📁 Lazarus is a free and open source development tool for the FreePascal Compiler. The purpose of the p
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  {should indicate whether or not to extract a given file}
  {  hfdi       - FDI context }
  {  pszCabinet - cabinet file name }
  {  pszCabPath - cabinet file path }
  {  flags      - currently not used }
  {  pfnfdin    - FDI notifaction callback function }
  {  pfnfdid    - decryption callback (currently not used)}
  {  Archive    - the calling TAbCabArchive instance }
{----------------------------------------------------------------------------}
function FDIDestroy(hfdi : HFDI) : Boolean;
  {releases FDI context and frees resources}
  {  hfdi - FDI context }
{----------------------------------------------------------------------------}
function FCICreate(pError : PCabErrorRecord;
  pfnfcifp, pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose,
  pfnseek, pfndelete, pfnfcigtf : FARPROC;
  pccab : PFCICabInfo; Archive : Pointer) : HFCI;
  {creates a new cabinet file and returns the FCI context}
  {  pError    - pointer to error record }
  {  pfnfcifp  - callback notification when file has been placed in cabinet }
  {  pfnalloc  - callback function to allocate memory }
  {  pfnfree   - callback function to free memory }
  {  pfnopen   - callback function to open a file }
  {  pfnwrite  - callback function to write to a file }
  {  pfnclose  - callback function to close a file }
  {  pfnseek   - callback function to reposition file pointer }
  {  pfndelete - callback function to delete a file }
  {  pfnfcigtf - callback function to obtain temp filename }
  {  pccab     - pointer to FCI cabinet infor structure }
  {  Archive   - the calling TAbCabArchive instance }
{----------------------------------------------------------------------------}
function FCIAddFile(hfci : HFCI; pszFilePath, pszFileName : PChar;
  fExecute : Boolean; pfnfcignc, pfnfcis, pfnfcigoi : FARPROC;
  typeCompress : Word) : Boolean;
  {adds a file to the cabinet}
  {  hfci         - FCI context }
  {  pszFilePath  - full pathname of file being added }
  {  pszFileName  - just the file name }
  {  fExecute     - flag to indicate if file is executable }
  {  pfnfcignc    - callback function to obtain next cabinet info }
  {  pfnfcis      - callback function to relay progress }
  {  pfnfcigoi    - callback function to open file and get attributes }
  {  typeCompress - compression type to use }
{----------------------------------------------------------------------------}
function FCIFlushCabinet(hfci : HFCI; fGetNextCab : Boolean;
  pfnfcignc, pfnfcis : FARPROC) : Boolean;
  {writes current cabinet file out to disk and optionally starts a new one}
  {  hfci        - FCI context }
  {  fGetNextCab - flag indicating whether to start a new cabinet }
  {  pfnfcignc   - callback function to obtain next cabinet info }
  {  pfnfcis     - callback function to relay progress }
{----------------------------------------------------------------------------}
function FCIFlushFolder(hfci : HFCI;
  pfnfcignc, pfnfcis : FARPROC) : Boolean;
  {close current compression block and start a new one}
  {  hfci      - FCI context }
  {  pfnfcignc - callback function to obtain next cabinet info }
  {  pfnfcis   - callback function to relay progress }
{----------------------------------------------------------------------------}
function FCIDestroy(hfci : HFCI) : Boolean;
  {releases FCI context and frees resources}
  {  hfdi - FDI context }
{----------------------------------------------------------------------------}


implementation

uses
  AbExcept,
  AbConst;


var
  CabDLLLoaded        : Boolean;
  CabDLLHandle        : THandle;
  FDICreateProc       : TFDICreate;
  FDIIsCabinetProc    : TFDIIsCabinet;
  FDICopyProc         : TFDICopy;
  FDIDestroyProc      : TFDIDestroy;
  FCICreateProc       : TFCICreate;
  FCIAddFileProc      : TFCIAddFile;
  FCIFlushCabinetProc : TFCIFlushCabinet;
  FCIFlushFolderProc  : TFCIFlushFolder;
  FCIDestroyProc      : TFCIDestroy;


{============================================================================}
procedure LoadCabinetDLL;
begin
  if CabDllLoaded then
    Exit;
//  CabDllHandle := LoadLibrary(CabinetDLL);
  if (CabDllHandle = 0) then
    raise EAbNoCabinetDLL.Create;
{$ifdef MSWINDOWS}
  @FDICreateProc := GetProcAddress(CabDllHandle, 'FDICreate');
  @FDIIsCabinetProc := GetProcAddress(CabDllHandle, 'FDIIsCabinet');
  @FDICopyProc := GetProcAddress(CabDllHandle, 'FDICopy');
  @FDIDestroyProc := GetProcAddress(CabDllHandle, 'FDIDestroy');
  @FCICreateProc := GetProcAddress(CabDllHandle, 'FCICreate');
  @FCIAddFileProc := GetProcAddress(CabDllHandle, 'FCIAddFile');
  @FCIFlushCabinetProc := GetProcAddress(CabDllHandle, 'FCIFlushCabinet');
  @FCIFlushFolderProc := GetProcAddress(CabDllHandle, 'FCIFlushFolder');
  @FCIDestroyProc := GetProcAddress(CabDllHandle, 'FCIDestroy');
  CabDllLoaded := True;
{$endif}
end;
{----------------------------------------------------------------------------}
function FDICreate(pfnalloc, pfnfree, pfnopen, pfnread,
  pfnwrite, pfnclose, pfnseek : FARPROC;
  cpuType  : Integer; pError : PCabErrorRecord) : HFDI;
begin
  LoadCabinetDLL;
  if Assigned(FDICreateProc) then
    Result := FDICreateProc(pfnalloc, pfnfree, pfnopen, pfnread,
      pfnwrite, pfnclose, pfnseek, cpuType, pError)
  else
    Result := nil;
end;
{----------------------------------------------------------------------------}
function FDIIsCabinet(hfdi : HFDI; hf : Integer;
  pfdici : PFDICabInfo) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FDIIsCabinetProc) then
    Result := FDIIsCabinetProc(hfdi, hf, pfdici)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FDICopy(hfdi : HFDI; pszCabinet, pszCabPath : PChar;
  flags : Integer; pfnfdin, pfnfdid : FARPROC;
  Archive : Pointer) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FDICopyProc) then
    Result := FDICopyProc(hfdi, pszCabinet, pszCabPath, flags,
      pfnfdin, pfnfdid, Archive)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FDIDestroy(hfdi : HFDI) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FDIDestroyProc) then
    Result := FDIDestroyProc(hfdi)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FCICreate(pError : PCabErrorRecord;
  pfnfcifp, pfnalloc, pfnfree, pfnopen, pfnread, pfnwrite, pfnclose,
  pfnseek, pfndelete, pfnfcigtf : FARPROC;
  pccab : PFCICabInfo; Archive : Pointer) : HFCI;
begin
  LoadCabinetDLL;
  if Assigned(FCICreateProc) then
    Result := FCICreateProc(pError, pfnfcifp, pfnalloc, pfnfree, pfnopen,
      pfnread, pfnwrite, pfnclose, pfnseek, pfndelete, pfnfcigtf,
      pccab, Archive)
  else
    Result := nil;
end;
{----------------------------------------------------------------------------}
function FCIAddFile(hfci : HFCI; pszFilePath, pszFileName : PChar;
  fExecute : Boolean; pfnfcignc, pfnfcis, pfnfcigoi : FARPROC;
  typeCompress : Word) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FCIAddFileProc) then
    Result := FCIAddFileProc(hfci, pszFilePath, pszFileName,
      fExecute, pfnfcignc, pfnfcis, pfnfcigoi, typeCompress)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FCIFlushCabinet(hfci : HFCI; fGetNextCab : Boolean;
  pfnfcignc, pfnfcis : FARPROC) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FCIFlushCabinetProc) then
    Result := FCIFlushCabinetProc(hfci, fGetNextCab, pfnfcignc, pfnfcis)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FCIFlushFolder(hfci : HFCI;
  pfnfcignc, pfnfcis : FARPROC) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FCIFlushFolderProc) then
    Result := FCIFlushFolderProc(hfci, pfnfcignc, pfnfcis)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
function FCIDestroy(hfci : HFCI) : Boolean;
begin
  LoadCabinetDLL;
  if Assigned(FCIDestroyProc) then
    Result := FCIDestroyProc(hfci)
  else
    Result := False;
end;
{----------------------------------------------------------------------------}
initialization
  CabDllLoaded := False;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -