Recent

Author Topic: [ SOLVED ]Abbrevia  (Read 553 times)

DanishMale

  • Jr. Member
  • **
  • Posts: 66
[ SOLVED ]Abbrevia
« on: November 30, 2022, 03:00:39 pm »
I try to create a ZIP-file which it does, however, there are no file inside the ZIP-file  ... it is simply empty??

It is expected to see a file called EEO.db3 inside the ZIP-file, but as you can see on the image there is no file there

Just a follow up question... which unit defines soStripDrive,soStripPath,soReplace for Abbrevia ?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.ZipBtnClick(Sender: TObject);
  2. var
  3.   Zip : TAbZipper;
  4.   ZipFileName: String;
  5. begin
  6.   try
  7.     ZipFileName := BackupFileFolderEdit.Text+FormatDateTime('YYYYMMDD', Now())+'.EEO_Backup.zip';
  8.     Zip := TAbZipper.Create(Application);
  9.     Zip.LogFile := BackupFileFolderEdit.Text+FormatDateTime('YYYYMMDD', Now())+'.zip.log';
  10.     Zip.Logging := True;
  11.     Zip.ArchiveType := atZip;
  12.     Zip.BaseDirectory := ExtractFilePath(ZipFileName);
  13.     Zip.TempDirectory := GetTempDir;
  14.     Zip.CompressionMethodToUse := smBestMethod;
  15.     Zip.DeflationOption := doNormal;
  16.   //  Zip.StoreOptions := [soStripDrive,soStripPath,soReplace];
  17.     Zip.FileName := ZipFileName;
  18.     Zip.AddFiles(ExtractFilePath(Application.ExeName)+'EEO.db3',0);
  19.     Zip.Save;
  20.     Zip.CloseArchive;
  21.     Zip.Free;
  22.   except
  23.     on E: Exception do
  24.     begin
  25.       ShowMessage(E.Message);
  26.     end;
  27.   end;
  28. end;
  29.  

I wonder what I am missing out here....

Thx in advance
« Last Edit: December 04, 2022, 07:56:27 am by DanishMale »
Lazarus 2.2.4 x64 | Windows 10 x64 | Windows Server 2019 x64 | OpenVix 5.4 (Linux) | MySQL Community Server 8.0 x64 | MariaDB 10.5.8 x64 | SQLite 3.40.0 x64 | PostgresSQL 13.1 x64

jamie

  • Hero Member
  • *****
  • Posts: 5046
Re: Abbrevia
« Reply #1 on: November 30, 2022, 11:12:56 pm »
Looks like a component meant for Delphi.

Lazarus has in its Libraries the component TZipper, and it works.


The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 10460
Re: Abbrevia
« Reply #2 on: December 01, 2022, 12:07:10 am »
In addition to what jamie wrote:

https://wiki.freepascal.org/paszlib
https://www.freepascal.org/docs-html/fcl/zipper/index.html

The FPC TZipper works very well. It used in fpspreadsheet to write Excel xlsx and LibreOffice ods files. I would not even think of replacing it by the famous, but unmaintained Abbrevia library.

jamie

  • Hero Member
  • *****
  • Posts: 5046
Re: Abbrevia
« Reply #3 on: December 01, 2022, 12:48:18 am »
I am slowly porting over a specialized CAD type of app that I prefer to preload lots of footprints from custom formats and I use the Zipper to do memory compression to keep them loaded in memory at all times.

  You would be surprised at how many footprints I can get in memory doing that.

  I don't have any performance issues because the ones that I am currently viewing, keeping alive are in their native state at that time.

The only true wisdom is knowing you know nothing

Ericktux

  • Sr. Member
  • ****
  • Posts: 318
Re: Abbrevia
« Reply #4 on: December 01, 2022, 04:23:11 am »
hello friend I use it like this with abbrevia:

Code: Pascal  [Select][+][-]
  1. uses
  2.  . . . . AbZipper, AbUnzper;
  3.  
  4. -----------
  5. procedure TForm1.Button1Click(Sender: Tobject);  // COMPRIMIR
  6. var
  7.   Zip : TAbZipper;
  8.  begin
  9.   Zip := TabZipper.Create(Application);
  10.   //zip.BaseDirectory := 'C:\Agenda TUX\';  // path del archivo a zipear, si no hay zipea todo el arbol
  11.   zip.FileName:= 'prueba.zip';  // archivo salida, si usamos “BaseDirectory” usar “'C:\Agenda TUX\'prueba.zip”
  12.   Zip.AddFiles('ericktux.txt',0);  // el archivo para zipear y “0” para que no toque otros archivos
  13.   // Zip.Password := '123';  // agregarle passwords
  14.   zip.Save;
  15.   zip.Free;
  16.  End;
  17.  
  18. procedure TForm1.Button2Click(Sender: Tobject);  // DESCOMPRIMIR
  19. var
  20.   uZip : TAbUnZipper;
  21.  begin
  22.   uZip := TabUnZipper.Create(Application);
  23.   //uzip.BaseDirectory := 'C:\Agenda TUX\';
  24.   uZip.FileName:= 'prueba.Zip';  // archivo salida, si usamos “BaseDirectory” usar “'C:\Agenda TUX\'prueba.zip”
  25.   // uZip.Password := '123';  // descomprimir con passwords
  26.   uZip.ExtractFiles('ericktux.txt'); // archivo dentro del ZIP a extraer
  27.   //uZip.CloseArchive;
  28.   uZip.Free;
  29.  End;    
 

with "zipper" I use it like this:

Code: Pascal  [Select][+][-]
  1. uses
  2. Zipper;
  3.  
  4. . . . . .
  5.  
  6. // COMPRESS
  7. var Zipper: TZipper;
  8. begin
  9.   Zipper:=TZipper.Create;
  10.   try
  11.     Zipper.FileName:='archive.zip';
  12.     Zipper.Entries.AddFileEntry('appnote.txt');
  13.     Zipper.ZipAllFiles;
  14.   finally
  15.     FreeAndNil(Zipper)
  16.   end;
  17. End;
  18.  
  19. // DESCOMPRESS
  20. function descomprimir_zip(File_ZIP, UnPackPath: String):Boolean;
  21. var
  22.   UnZipper: TUnZipper;
  23. begin
  24. Result:=false;
  25.   UnZipper := TUnZipper.Create;
  26.   try
  27.       try
  28.         UnZipper.FileName := File_ZIP;
  29.         UnZipper.OutputPath := UnPackPath;
  30.         UnZipper.Examine;
  31.         UnZipper.UnZipAllFiles;
  32.         Result:=true;
  33.         except
  34.               {
  35.               on E: Exception do
  36.         Write(E.Message);     //  ejemplo ShowMessage(E.Message);
  37.               }
  38.         Result:=false;
  39.         end;
  40.   finally
  41.     UnZipper.Free;
  42.   end;
  43. end;
  44.  
  45. // EXAMPLE:
  46.  
  47.   if descomprimir_zip('C:\Users\Win10\AppData\Local\Temp\myfiles\tool.zip','C:\ericktux_software') then
  48.   ShowMessage('exito')
  49.   else
  50.     ShowMessage('error');  
  51.  

I hope it works for you brother, regards

KodeZwerg

  • Hero Member
  • *****
  • Posts: 877
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Abbrevia
« Reply #5 on: December 01, 2022, 10:03:10 am »
Code: Pascal  [Select][+][-]
  1. uses Zipper;
  2. var Zipper
I would not use Duplicate names my friend.
« Last Edit: Tomorrow at 31:76:97 by KodeZwerg »

ccrause

  • Hero Member
  • *****
  • Posts: 686
Re: Abbrevia
« Reply #6 on: December 01, 2022, 10:11:58 am »
Code: Pascal  [Select][+][-]
  1.     Zip.AddFiles(ExtractFilePath(Application.ExeName)+'EEO.db3',0);

A quick look at the component source suggest that TABZipper will not generate an error if it cannot find a file.  Have you checked that the target file is actually at the location as generated above?  Perhaps add a check using FileExists from the sysutils unit to ensure the target file does exist.

jamie

  • Hero Member
  • *****
  • Posts: 5046
Re: Abbrevia
« Reply #7 on: December 01, 2022, 03:11:59 pm »
Well for one thing, the property field wasn't introduced in the file properties.

where he has 0 in the second field should be faAnyFile which isn't 0 the last time I looked.
The only true wisdom is knowing you know nothing

DanishMale

  • Jr. Member
  • **
  • Posts: 66
Re: [ SOLVED ]Abbrevia
« Reply #8 on: December 04, 2022, 07:58:51 am »
Found that somehow the file to be zipped was blocked someplace not identified, so I made a work around instead and this way the zipping is worked as intended!!! Simply exporting the data to a SQL file and zipping that file instead.

Thanks for all of your solutions and suggestions!!!!
Lazarus 2.2.4 x64 | Windows 10 x64 | Windows Server 2019 x64 | OpenVix 5.4 (Linux) | MySQL Community Server 8.0 x64 | MariaDB 10.5.8 x64 | SQLite 3.40.0 x64 | PostgresSQL 13.1 x64

 

TinyPortal © 2005-2018