Lazarus
Home
Forum
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
read and save zip files
Downloads
Daily Snapshots
FAQ
Wiki
Bugtracker
IRC channel
Developer Blog
Follow us on Twitter
Mailing List
Free pascal
Other languages
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
About donations (wiki)
Bookstore
Lazarus, the complete guide
Search
Advanced search
« previous
next »
Print
Pages: [
1
]
Author
Topic: read and save zip files (Read 1360 times)
dcelso
Full Member
Posts: 148
read and save zip files
«
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)
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #1 on:
February 07, 2013, 08:13:47 am »
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.
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #2 on:
February 07, 2013, 09:45:17 am »
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?
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #3 on:
February 07, 2013, 10:13:51 am »
Yes, AFAIR I used streams in checkride.
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #4 on:
February 07, 2013, 01:58:36 pm »
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?
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #5 on:
February 07, 2013, 02:18:57 pm »
I'd suggest you go through the paszlib/zipper source code.
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
User137
Hero Member
Posts: 1075
Re: read and save zip files
«
Reply #6 on:
February 07, 2013, 03:47:08 pm »
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.
Logged
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #7 on:
February 07, 2013, 06:43:33 pm »
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.
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #8 on:
February 07, 2013, 07:12:38 pm »
Ok, just to make it clear: gzip and zip are two different formats..
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #9 on:
February 07, 2013, 07:54:47 pm »
, yes, then, what do i need?
Logged
User137
Hero Member
Posts: 1075
Re: read and save zip files
«
Reply #10 on:
February 07, 2013, 08:07:31 pm »
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
Logged
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #11 on:
February 07, 2013, 08:37:55 pm »
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
) but I need do the same in lazarus
.
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #12 on:
February 07, 2013, 09:21:03 pm »
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.
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
dcelso
Full Member
Posts: 148
Re: read and save zip files
«
Reply #13 on:
February 07, 2013, 10:24:20 pm »
. Thanks so much. I will study it
Logged
BigChimp
Hero Member
Posts: 3341
Re: read and save zip files
«
Reply #14 on:
February 09, 2013, 09:22:06 am »
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!
Logged
Want quicker answers to your questions? Read
http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F
Open source including twitter/Oauth library:
https://bitbucket.org/reiniero
Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
read and save zip files
Recent
Code critique required - ...
by
JuhaManninen
[
Today
at 01:06:56 am]
Future of Lazarus / FreeP...
by
JanRoza
[June 18, 2013, 11:57:21 pm]
Closing an application.
by
Zath
[June 18, 2013, 11:46:07 pm]
add txt file contents to ...
by
Zath
[June 18, 2013, 11:21:12 pm]
New form or panel etc.
by
Zath
[June 18, 2013, 11:16:57 pm]
Lazarus 1.10 / Ubuntu 13....
by
Martin_fr
[June 18, 2013, 10:26:51 pm]
GIF support for TIpHtmlPa...
by
shadow
[June 18, 2013, 10:15:46 pm]
RWLock version 1.01
by
aminer
[June 18, 2013, 09:51:19 pm]
Cloned source editor wind...
by
Martin_fr
[June 18, 2013, 08:19:06 pm]
FileSize always returns 1...
by
kpeters58
[June 18, 2013, 08:10:08 pm]