Lazarus
Programming => General => Topic started by: dcelso on February 07, 2013, 01:55:34 am
-
Hello to all, I would like know the differents alternatives to open zip files and if lazarus have official support to this.
I need to open and save a zipped file with have compressesd with simple format zip ( one file inside zip that uses the same name that the zip)
-
There's built in zip support. See the wiki:
http://wiki.lazarus.freepascal.org/paszlib
Example of use on the page; I've used it succesfully in my CheckRide open source program (see repository below); many others used it, too.
-
thanks, I read it before.
But I would like use zip like a Stream. Some like
szip : = tzipstream.create(filename)
szip.read(mypbyte,mylenght);
szip.free;
and after do similar to save
szip : = tzipstream.create(filename)
szip.write(mypbyte,mylenght);
szip.free;
Is there possible with paszlib?
-
Yes, AFAIR I used streams in checkride.
-
thanks, but i read all your .pas files from https://bitbucket.org/reiniero/checkride/, without find an example of use zlib as I put before.
¿Can you adapt this code to use paszlib?
-
I'd suggest you go through the paszlib/zipper source code.
-
Do you need it specifically in ZIP format, or is any compression ok? If any is fine, i'd suggest also checking TCompressionStream and TDeCompressionStream.
Zip format might not be that simple... There should be a reason, why apps like Winzip have to decompress the whole file first, if they want to add more files to it, or maybe even if they only want to read 1 file from it. In short it could a complete mess, compared to clear structure you could make to your own file format. Those streams should pack as tight as ZIP anyway.
-
umm, I need open zipfiles compressed with standard gzip as this example
gzip -nc file_in.txt > file_out.gz (no named file)
The Idea is do transparent to the end user the compression of the generated files with the program, so the end user unknow if the created custom fileformat of my program is compressed or dont, because he can open and save the custom genetated files of my program unknowing it internal contend.
Y need use the same compress method that gzip uses in the command before, because my application would open and save the file-format of the other existing application that do it, or compres and uncompress using gzip common tools.
-
Ok, just to make it clear: gzip and zip are two different formats..
-
:o, yes, then, what do i need?
-
It seems that gzip only supports 1 file in it. So *nix pack multiple files into .tar first, and then gzip. So you need to decide which one you are after: tar+gzip, or zip? You can use windows-like zip on linux too.
http://superuser.com/questions/334827/how-to-gzip-multiple-files-into-one-gz-file
-
exactly, i dont want multiple files into it. If you read the entire post you can understand it.
i need exacly the same that do
gzip -nc fileungzipped > filegzipped.gz
and the contrary
gzip -dc filegzipped.gz > fileunfzipped
an example of use would be like a tfilestream,create but instead of read from a uncompressed file read from a gzipped file directly.
In Java I do it exactly that I say,(using gzipinputstream (http://docs.oracle.com/javase/1.4.2/docs/api/java/util/zip/GZIPInputStream.html)) but I need do the same in lazarus :D.
-
IIIRC, paszlib supports streams... Why dont you look up the source code in the fpc source directory.
I think perhaps the example program for paszlib may use streams but am not sure.
-
:o. Thanks so much. I will study it
-
Mmm, had some time to look myself. Seems there's quite some low level paszlib stuff where at least streams are used.
Haven't been able to find higher level example programs using streams...
Hope you found something!