Recent

Author Topic: paszlib. Determine if extraction was successful  (Read 258 times)

LemonParty

  • Sr. Member
  • ****
  • Posts: 393
paszlib. Determine if extraction was successful
« on: November 07, 2025, 12:35:03 pm »
I use TUnZipper.UnZipAllFiles to extract archive.
How to determine if extraction of all files was successful?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: paszlib. Determine if extraction was successful
« Reply #1 on: November 07, 2025, 01:11:45 pm »
The unzipper raises a lot of exceptions. So, if your unzipping procedure reaches its end without an exception it must have been successful. Untested:
Code: Pascal  [Select][+][-]
  1. uses
  2.   Zipper;
  3. function UnzipFiles(AZip: String; AOutputDir: String; out AErrorMsg: String): Boolean;
  4. var
  5.   UnZipper: TUnZipper;
  6. begin
  7.   Result := true;
  8.   AErrorMsg := '';
  9.   UnZipper := TUnzipper.Create;
  10.   try    
  11.     try  
  12.       UnZipper.FileName := AZip;
  13.       UnZipper.OutputPath := AOutputDir;
  14.       UnZipper.Examine;
  15.       UnZipper.UnZipAllFiles;
  16.     except
  17.       on E:Exception do
  18.       begin
  19.         AErrorMsg := E.Message;
  20.         Result := false;
  21.       end;
  22.     end;
  23.   finally
  24.     UnZipper.Free;
  25.   end;
  26. end;
  27. end.
  28.  

Thaddy

  • Hero Member
  • *****
  • Posts: 18703
  • To Europe: simply sell USA bonds: dollar collapses
Re: paszlib. Determine if extraction was successful
« Reply #2 on: November 07, 2025, 01:35:11 pm »
The unzipper raises a lot of exceptions.
Oops, that needs a rewrite then.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

 

TinyPortal © 2005-2018