Sign in Join

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

Mailing lists / fpc-pascal / 2008-01

FPC Zip library

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Felipe Monteiro de Carvalho

Hello,

Does anyone know a zip library for fpc that can create a directory structure inside the zip?

I am implementing a generic spreadsheet library, and I was considering adding either OpenDocument or OOXML to it, so it really needs to be a zip file with a directory structure inside.

thanks,

Felipe Monteiro de Carvalho
Graeme Geldenhuys
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Hello, Does anyone know a zip library for fpc that can create a directory structure inside the zip?

Yup. Darius Blaszijk and I worked on a TZipFile project (Darius did most of it) where you can access the inside of a zipfile in the same way as a normal directory. Create, Delete and View files and directories etc... Compression is still not working 100% - I still need to find some time to debug it. But if you have a zip file with no compression, it works perfectly. We created the project for things like a new help file format where all content is stored in a zip archive and viewed directly from the zip file. Darius might have had other plans to.

Have a look at:

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

Regards,
- Graeme -

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

Michael Van Canneyt
to Felipe Monteiro de Carvalho: Does anyone know a zip library for fpc that can create a directory structure inside the…
Felipe Monteiro de Carvalho wrote 8 lines
Hello, Does anyone know a zip library for fpc that can create a directory structure inside the zip? I am implementing a generic spreadsheet library, and I was considering adding either OpenDocument or OOXML to it, so it really needs to be a zip file with a directory structure inside.

Doesn't the zipper unit that comes standard with FPC suit your needs ? As far as I know, there is no special treatment needed for directories, just add the file with a name like subdir/filename.ext ?

Michael.

Felipe Monteiro de Carvalho
to Michael Van Canneyt
Michael Van Canneyt wrote
Doesn't the zipper unit that comes standard with FPC suit your needs ? As far as I know, there is no special treatment needed for directories, just add the file with a name like subdir/filename.ext ?

oh, I had done a search on fpc directories but I somehow missed it =)

thanks for the responses,

Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho
to Michael Van Canneyt: Doesn't the zipper unit that comes standard with FPC suit your needs ? As far as I know,…
Michael Van Canneyt wrote
Doesn't the zipper unit that comes standard with FPC suit your needs ? As far as I know, there is no special treatment needed for directories, just add the file with a name like subdir/filename.ext ?

Well, I tryed it, but I got stuck with some problems:

1 - I couldn't find anyway to tell it how the file will be called inside the Zip file, and therefore I can't add the file "with a name"

There is TZipper.ZipFiles and receives a TStringList with the names of the files on disk to be zipped. There is no parameter to tell how the files will be called inside the Zip file.

I tryed to follow the code to see it something like that is possible, and a found a TZipItem with some structure members about a path. Unfortunately both refer too to the file on the disk that will be zipper, nothing about the name inside the zip file.

2 - It doesn't allow to give a stream of data to be compressed into a zip file. My data is on memory, saving it and re-reading is a waste. This one is easy to fix without knowledge of zip format, and I started building a TZipper. ZipStreams, but then I met problem 1 and gave up, because it is a show stopper, and not at all easy to solve (I don't understand anything about zip file structure).

thanks,

Felipe Monteiro de Carvalho
Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 9 lines
On Jan 28, 2008 10:07 PM, Michael Van Canneyt wrote: > Doesn't the zipper unit that comes standard with FPC suit your needs ? > As far as I know, there is no special treatment needed for directories, > just add the file with a name like subdir/filename.ext ? Well, I tryed it, but I got stuck with some problems: 1 - I couldn't find anyway to tell it how the file will be called inside the Zip file, and therefore I can't add the file "with a name"

It has the same name as the TStringlist item.

There is TZipper.ZipFiles and receives a TStringList with the names of the files on disk to be zipped. There is no parameter to tell how the files will be called inside the Zip file.

Same name.

Show quoted text 5 lines
I tryed to follow the code to see it something like that is possible, and a found a TZipItem with some structure members about a path. Unfortunately both refer too to the file on the disk that will be zipper, nothing about the name inside the zip file.

I'm sure this can easily be remedied.

Show quoted text 7 lines
2 - It doesn't allow to give a stream of data to be compressed into a zip file. My data is on memory, saving it and re-reading is a waste. This one is easy to fix without knowledge of zip format, and I started building a TZipper. ZipStreams, but then I met problem 1 and gave up, because it is a show stopper, and not at all easy to solve (I don't understand anything about zip file structure).

This is a bit harder, and needs to be looked into.

If you could add these as feature requests on the bugtracker, then
I won't forget about them...

Michael.

Felipe Monteiro de Carvalho
to Michael Van Canneyt
If you could add these as feature requests on the bugtracker, then I won't forget about them...

Done, thanks a lot.

I've made good progress creating OOXML files from code by the way. If you zip the files manually it works good.

Felipe Monteiro de Carvalho
Graeme Geldenhuys
to Felipe Monteiro de Carvalho: Well, I tryed it, but I got stuck with some problems: 1 - I couldn't find anyway to tell…
Felipe Monteiro de Carvalho wrote 7 lines
2 - It doesn't allow to give a stream of data to be compressed into a zip file. My data is on memory, saving it and re-reading is a waste. This one is easy to fix without knowledge of zip format, and I started building a TZipper. ZipStreams, but then I met problem 1 and gave up, because it is a show stopper, and not at all easy to solve (I don't understand anything about zip file structure).

We have already done this in tiOPF. We can compress a string, file or stream using gzip. Um, that's using a single item for compression, so might not be what you want. Anyway, I have also stripped the code to have no tiOPF dependencies. If you are interested, I will try and find the code for you.

Alternatively, have a look at the TZipFile component I mentioned before. It does what you want - I think. Plus it has functions to list, view and save files and directories inside a zip file. It's like working with a normal directory structure. Darius did a brilliant job of it.

Regards,
- Graeme -

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