Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-02

Zipfiles using Paszlib...

24 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reenen Laurie

Hi,

I am trying to create zip files for my application (using Paszlib's Zip and ziptools), using the "store" method. However, none of the zipfiles I've created works.

I've tested the "minizip" example in the FPC folder, and after I compiled it (on linux) by symlinking to zlib.pp in packages/zlib/src/, it works. Minizip makes the zipfiles apparently right (as normal archivers can unzip it, unlike my zip files I've created).

So now I've "used" zlib in my Lazarus project, but it complains about not finding libz... which is a library that gets included in zlib.pp : {$linklib libz}

My project compiles fine without using 'zlib', but then it fails to create files. Now I've added uses zlib, but now it doesn't compiled.

I *think* I am pretty much following minizip's example, but somehow my files isn't creating the "stored" zip files that I am hoping for.

If anybody has any experience working with zip files, I'd be grateful if they can point me to where the caveats are that I've not looked at.

Regards,
-Reenen

o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090209/5a32961a/attachment.html

Reply by email

Hans-Peter Diettrich
to Reenen Laurie
My project compiles fine without using 'zlib', but then it fails to create files. Now I've added uses zlib, but now it doesn't compiled.

Don't confuse zlib with zip. AFAIK zlib is the gz library, which compresses only an single file, and typically is used to compress tar archives into *.tar.gz or *.tgz.

DoDi

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
Don't confuse zlib with zip. AFAIK zlib is the gz library, which compresses only an single file, and typically is used to compress tar archives into *.tar.gz or *.tgz.

That's correct. An alternative that also gives MUCH better compression, is 7zip. There is a native implementation of 7zip for Delphi (and I believe it works with Free Pascal as well). Good news is that NO external libraries are required and compression is the best!

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

JoshyFun
to Graeme Geldenhuys

Hello Graeme,

Monday, February 9, 2009, 9:38:32 AM, you wrote:

GG> That's correct. An alternative that also gives MUCH better GG> compression, is 7zip. There is a native implementation of 7zip for GG> Delphi (and I believe it works with Free Pascal as well). Good news is GG> that NO external libraries are required and compression is the best!

Where's that 7Zip Delphi unit ? I was unable to find it, except a bunch of API headers and others that need the 7za.dll

Best regards, JoshyFun

Reply by email

Graeme Geldenhuys
to JoshyFun
JoshyFun wrote
Where's that 7Zip Delphi unit ? I was unable to find it, except a bunch of API headers and others that need the 7za.dll

http://www.7-zip.org/sdk.html

Delphi / Free Pascal link is at the bottom of that page. Please note I haven't used it myself, but plan on doing so during this year.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

JoshyFun
to Graeme Geldenhuys

Hello Graeme,

Monday, February 9, 2009, 3:04:33 PM, you wrote:

GG> http://www.7-zip.org/sdk.html

GG> Delphi / Free Pascal link is at the bottom of that page. Please note I GG> haven't used it myself, but plan on doing so during this year.

Thank you but this one only handles the LZMA compression/decompression but nothing to deal with the 7zip file format, anyway the handling of the file format is much more easy for sure than the coding of the LZMA algorithm.

I'll try to write a 7zip file parser for my virtual file system and the LZMA will handle the decompression in almost all cases, compression will be the second step ;)

Best regards, JoshyFun

Reply by email

Reenen Laurie
to JoshyFun

My needs are pretty simple...

I want something that will combine X files into 1 file, and then later read any 1 of those X file back into either a TImage (Jpg etc.) or into a TStringlist.

I don't have many restrictions... My files won't likely be more than 500kb, and typically won't contain 30 files (or even 10).

So if someone has a "virtual file system" somewhere available, then that'll work too. I am a little pushed for time, and if someone can point me to someplace where this is done I'd greatly appreciate it.

Thanks!

Regards,
-Reenen

JoshyFun wrote 27 lines
Hello Graeme, Monday, February 9, 2009, 3:04:33 PM, you wrote: GG> http://www.7-zip.org/sdk.html GG> Delphi / Free Pascal link is at the bottom of that page. Please note I GG> haven't used it myself, but plan on doing so during this year. Thank you but this one only handles the LZMA compression/decompression but nothing to deal with the 7zip file format, anyway the handling of the file format is much more easy for sure than the coding of the LZMA algorithm. I'll try to write a 7zip file parser for my virtual file system and the LZMA will handle the decompression in almost all cases, compression will be the second step ;) -- Best regards, JoshyFun _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090209/89d7f870/attachment.html

Reply by email

Reenen Laurie
to Reenen Laurie

Initially I don't even need the files inside to be editable...

Reenen Laurie wrote 61 lines
My needs are pretty simple... I want something that will combine X files into 1 file, and then later read any 1 of those X file back into either a TImage (Jpg etc.) or into a TStringlist. I don't have many restrictions... My files won't likely be more than 500kb, and typically won't contain 30 files (or even 10). So if someone has a "virtual file system" somewhere available, then that'll work too. I am a little pushed for time, and if someone can point me to someplace where this is done I'd greatly appreciate it. Thanks! Regards, -Reenen On Mon, Feb 9, 2009 at 5:13 PM, JoshyFun wrote: > Hello Graeme, > > Monday, February 9, 2009, 3:04:33 PM, you wrote: > > GG> http://www.7-zip.org/sdk.html > > GG> Delphi / Free Pascal link is at the bottom of that page. Please note I > GG> haven't used it myself, but plan on doing so during this year. > > Thank you but this one only handles the LZMA compression/decompression > but nothing to deal with the 7zip file format, anyway the handling of > the file format is much more easy for sure than the coding of the LZMA > algorithm. > > I'll try to write a 7zip file parser for my virtual file system and > the LZMA will handle the decompression in almost all cases, > compression will be the second step ;) > > -- > Best regards, > JoshyFun > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > -- o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions.
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090209/a7fcdf1f/attachment.html

Reply by email

Vincent Snijders
to Reenen Laurie: My needs are pretty simple... I want something that will combine X files into 1 file, and…
Reenen Laurie wrote 13 lines
My needs are pretty simple... I want something that will combine X files into 1 file, and then later read any 1 of those X file back into either a TImage (Jpg etc.) or into a TStringlist. I don't have many restrictions... My files won't likely be more than 500kb, and typically won't contain 30 files (or even 10). So if someone has a "virtual file system" somewhere available, then that'll work too. I am a little pushed for time, and if someone can point me to someplace where this is done I'd greatly appreciate it.

LibTar may be something for you:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/utils/libtar.pas?revision=7169&content-type=text%2Fplain

Vincent

Reply by email

Graeme Geldenhuys
to Reenen Laurie: My needs are pretty simple... I want something that will combine X files into 1 file, and…

2009/2/9 Reenen Laurie :

My needs are pretty simple...

That's what we all say. :-)

So if someone has a "virtual file system" somewhere available, then that'll work too. I am a little pushed for time, and if someone can point me to someplace where this is done I'd greatly appreciate it.

You could also try TZipFile located in the following SVN repository. It doesn't contain compression yet, but does place files and folders inside a .zip archive. It has file handling routines, so it feels like you are working with normal files in a directory, but they are actually inside a zip archive.

https://svn.sourceforge.net/svnroot/modelbuilder/src/trunk/mcl/zipfile

Later in the year I want to extend TZipFile with compression (if it doesn't already have) and use it as our custom help file format for our company applications.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Felipe Monteiro de Carvalho
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
You could also try TZipFile located in the following SVN repository. It doesn't contain compression yet, but does place files and folders inside a .zip archive. It has file handling routines, so it feels like you are working with normal files in a directory, but they are actually inside a zip archive.

The TZipper from FPC subversion can add files to a zip archive in any directory structure desired and also compress them. It worked very well for me to generate OOXML and OpenDocument files. But you have to use the latest subversion zipper.pp files, the current one doesn't have the needed fixes

USage:

  FZipper.FileName:=ParamStr(1);
  For I:=2 to ParamCount do
    begin
    F:=TFileStream.Create(ParamStr(i),fmOpenRead);
    FZipper.Entries.AddFileEntry(F,ParamStr(i));
    end;
  FZipper.ZipAllFiles;
  For I:=0 to FZipper.Entries.Count-1 do
    FZipper.Entries[I].Stream.Free;
Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: 2009/2/9 Reenen Laurie : That's what we all say. :-) You could also try TZipFile located…
Later in the year I want to extend TZipFile with compression (if it doesn't already have) and use it as our custom help file format for our company applications.

I've already been working on a general compression/archive interface, based on the Abbrevia approach. Unfortunately Abbrevia at that time already had become so buggy, that I designed a better interface for the integration of compression modules of any kind. It proved to be usable with most archives, like rpm/cpio, tar/gz and zip. Finally I stopped working on porting more modules to Pascal, when I found that 7zip already has implemented such an interface, and also has solved the integration of existing compressors.

I like the idea of integrating existing code for the worker objects, so that the evolution of existing and new modules (almost in C code) is decoupled from the interface itself. I only don't like the 7zip implementation in C++, because it is not portable.

My approach consists of both Delphi classes, encapsulating the various kinds of archives, as well as a generalized component for the visual interface. The single-component model was inspired by database components, which also can be connected to various kinds of databases. The interface effectively consists of an set of fixed attributes and methods, common to all archivers, and archive-specific attributes and features, accessible as name/value string pairs. I'm willing to resume my work on this approach, if somebody familiar with C can implement the low level stuff (calls to the worker C code).

DoDi

Reply by email

Graeme Geldenhuys
to Felipe Monteiro de Carvalho: On Tue, Feb 10, 2009 at 7:46 AM, Graeme Geldenhuys The TZipper from FPC subversion can…
Felipe Monteiro de Carvalho wrote
The TZipper from FPC subversion can add files to a zip archive in any directory structure desired and also compress them.

I have never you have any idea how that differs
from TZipFile? Is it worth picking one over the other?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Reenen Laurie
to Graeme Geldenhuys: 2009/2/9 Reenen Laurie : That's what we all say. :-) You could also try TZipFile located…

Thank you all for all the great responses! I greatly appreciate it, and I'm glad to see that there is several options I can try.

I am/was using a program called TZipFile. I don't know if it's the same thing. I found it on the wiki.

For me creating a /new/ zip file failed on files that were bigger than 64kb. I was so far unable to determine the exact cause of this, but it has caused me to start looking for alternatives.

I've downloaded now the File System that Joshy Fun sent, and it's quite imposing, but looks like it has potential...

I'll also have a look at some of the other suggestions mentioned. (libtar, TZipper, etc).

Thanks!

Regards,
-Reenen

Graeme Geldenhuys wrote 36 lines
2009/2/9 Reenen Laurie : > My needs are pretty simple... That's what we all say. :-) > So if someone has a "virtual file system" somewhere available, then that'll > work too. I am a little pushed for time, and if someone can point me to > someplace where this is done I'd greatly appreciate it. You could also try TZipFile located in the following SVN repository. It doesn't contain compression yet, but does place files and folders inside a .zip archive. It has file handling routines, so it feels like you are working with normal files in a directory, but they are actually inside a zip archive. https://svn.sourceforge.net/svnroot/modelbuilder/src/trunk/mcl/zipfile Later in the year I want to extend TZipFile with compression (if it doesn't already have) and use it as our custom help file format for our company applications. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090210/4e0daed2/attachment.html

Reply by email

Felipe Monteiro de Carvalho
to Graeme Geldenhuys: On Tue, Feb 10, 2009 at 11:07 AM, Felipe Monteiro de Carvalho I have never you have any…
Graeme Geldenhuys wrote
I have never you have any idea how that differs from TZipFile? Is it worth picking one over the other?

I've never used TZipFile, but well, you wrote that TZipFile doesn't compress. TZipper does compress, and TZipper is a standard component of Free Pascal. Althougth at the moment you need a local copy of the latest svn zipper.pp to use it.

Another nice feature of TZipper is adding files with a stream as source, so you can load data from any where you want, doesn't need to be existing files. Don't know if TZipFiles also allows that.

Felipe Monteiro de Carvalho

Reply by email

Graeme Geldenhuys
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 5 lines
I've never used TZipFile, but well, you wrote that TZipFile doesn't compress. TZipper does compress, and TZipper is a standard component of Free Pascal. Althougth at the moment you need a local copy of the latest svn zipper.pp to use it.

Thanks Felipe. I'll take a closer look at both and try to merge any feature between the two. I would prefer something that is standard in FPC as well.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Reenen Laurie
to Felipe Monteiro de Carvalho

Hi all.

Again thank you for a whole new world that opened up to me. Eventually i went with libtar, but i'll run into trouble on editing it live later... But for the size of my files it shouldn't bother much.

Thanks again!

-Reenen

Felipe Monteiro de Carvalho wrote 18 lines
On Wed, Feb 11, 2009 at 9:23 AM, Graeme Geldenhuys wrote: > Thanks Felipe. I'll take a closer look at both and try to merge any > feature between the two. I would prefer something that is standard in > FPC as well. I added step-by-step instructions on how to get the latest TZipper and use it to the wiki: http://wiki.lazarus.freepascal.org/paszlib -- Felipe Monteiro de Carvalho _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
o__ ,_.>/ _ (_)_\(_)_______ ...speed is good _______________ I believe five out of four people have a problem with fractions.

Reply by email

Lee Jenkins
to Felipe Monteiro de Carvalho: On Wed, Feb 11, 2009 at 9:23 AM, Graeme Geldenhuys I added step-by-step instructions on…
Felipe Monteiro de Carvalho wrote 9 lines
On Wed, Feb 11, 2009 at 9:23 AM, Graeme Geldenhuys wrote: > Thanks Felipe. I'll take a closer look at both and try to merge any > feature between the two. I would prefer something that is standard in > FPC as well. I added step-by-step instructions on how to get the latest TZipper and use it to the wiki:

I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based and only called TZipper?

Thanks,

Warm Regards, Lee

Reply by email

Felipe Monteiro de Carvalho
to Lee Jenkins
Lee Jenkins wrote
I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based and only called TZipper?

I don't understand your question.

The files produced work correctly if given the .zip extension. They are recognized by the internal unzipper of OpenOffice.org

Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho
Show quoted text 7 lines
> I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based > and only called TZipper? I don't understand your question. The files produced work correctly if given the .zip extension. They are recognized by the internal unzipper of OpenOffice.org

You assume that OO only looks at the file extension, not at the actual file contents?

DoDi

Reply by email

Sergei Gorelkin
to Lee Jenkins: I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based and only…
Lee Jenkins wrote
I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based and only called TZipper?

Yes, it produces pkZIP compatible files and yes, it uses zlib for compression.
.zip file format deals only with overall archive file structure (headers, directories, etc). Each individual file within .zip archive may be compressed using its own method, or even not most popular compression format used in .zip files is 'deflate', which is handled perfectly well with zlib. The difference with .gz format is only that compressed stream is written without .gz header.

Regards,
Sergei

Reply by email

Felipe Monteiro de Carvalho
to Hans-Peter Diettrich: You assume that OO only looks at the file extension, not at the actual file contents? DoDi
Hans-Peter Diettrich wrote
>> I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based >> and only called TZipper?

What is pkZIP?

You assume that OO only looks at the file extension, not at the actual file contents?

I assume it can only uncompress 1 format, unless zip files can be compressed in multiple ways and I don't know it.

Felipe Monteiro de Carvalho

Reply by email

Lee Jenkins
to Sergei Gorelkin: Yes, it produces pkZIP compatible files and yes, it uses zlib for compression. .zip file…
Sergei Gorelkin wrote 13 lines
Lee Jenkins wrote: > I'm confused. Does TZipper produce pkZIP compatible files or is it zlib based > and only called TZipper? > Yes, it produces pkZIP compatible files and yes, it uses zlib for compression. .zip file format deals only with overall archive file structure (headers, directories, etc). Each individual file within .zip archive may be compressed using its own method, or even not compressed at all. The most popular compression format used in .zip files is 'deflate', which is handled perfectly well with zlib. The difference with .gz format is only that compressed stream is written without .gz header.

Thanks for that, Sergei. I wasn't aware of that and thought that they used incompatible compression algorithms.

Thanks again,

Warm Regards, Lee

Reply by email