Recent

Author Topic: Decompress GZIP Stream  (Read 14421 times)

Chris95

  • Newbie
  • Posts: 4
Decompress GZIP Stream
« on: October 24, 2014, 12:00:38 pm »
There are examples to decompress gzip files but no example to decompress gzip stream.Can somebody help me a working example?
Thanks in advance!

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #1 on: October 24, 2014, 11:46:07 pm »
« Last Edit: October 24, 2014, 11:55:43 pm by sam707 »

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #2 on: October 24, 2014, 11:48:52 pm »
add
 
Code: [Select]
uses
  ZLib;
to an unit

 open the zlib.pp file in your lazarus distro ( [Ctrl]+mouseclick on 'zlib' text in your uses clause), and learn from scratch
« Last Edit: October 24, 2014, 11:52:48 pm by sam707 »

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #3 on: October 25, 2014, 12:09:33 am »
http://wiki.freepascal.org/paszlib

http://sageshome.net/oss/paszlib-sg.php

you can also learn from unit zstream

Code: [Select]
uses
  zstream;

which handles both zip and gz format

see Tcompressionstream/Tdecompressionstream in that zstream unit
« Last Edit: October 25, 2014, 02:42:56 am by sam707 »

Chris95

  • Newbie
  • Posts: 4
Re: Decompress GZIP Stream
« Reply #4 on: October 25, 2014, 05:10:26 am »
So in the last 6 years nobody managed to do it? :'(
Now seriously I already looked at those units and if I try to modify a function it will break another function and so on...
I'm a newbie and I don't know how to do it this is why I ask for a working example.
Thank you!

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #5 on: October 25, 2014, 05:42:35 am »
hm if you can't know how to call a Class.Create and then call few procedures and functions just by using zstream unit, consider :

1) learn pascal from the very very BEGINING

2) or look for a welder job

no offense Sir, but the units I mentionned are very Clear, Simple, EASY to use NO NEED EXAMPLES!!!
« Last Edit: October 25, 2014, 05:47:14 am by sam707 »

Chris95

  • Newbie
  • Posts: 4
Re: Decompress GZIP Stream
« Reply #6 on: October 25, 2014, 05:57:21 am »
1. Yes I'm trying to learn pascal but because I don't have a teacher I'm trying to learn from examples.

2.It's just a hobby. 8-)

3.I think you don't know either how to decompress gzip steams. :P

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #7 on: October 25, 2014, 05:59:51 am »
of course not , I am Perceval Knight, a cousin from WhiteSnow's dwarves ;)... and I can't know pascal lol I'm just passing by, here, dancing dressed in a pink tutu  :D
« Last Edit: October 25, 2014, 06:08:34 am by sam707 »

jarto

  • Full Member
  • ***
  • Posts: 106
Re: Decompress GZIP Stream
« Reply #8 on: October 25, 2014, 08:42:36 am »
So in the last 6 years nobody managed to do it? :'(

The easiest way is by using tpAbbrevia. Even then, you need to do one change to TAbArchive.ExtractToStream in AbArcTyp.pas:

Code: [Select]
-  Index := FindFile(aFileName);
-  if (Index = -1) then
-    Exit;
+  if aFileName<>'' then begin
+    Index := FindFile(aFileName);
+    if (Index = -1) then
+      Exit;
+  end else begin
+    Index:=0;
+    ExtractItemToStreamAt(Index, aStream);
+    exit;
+  end;

TCompressionStream and TDecompressionStream, that sam707 mentioned earlier, are unfortunately not gzip.

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #9 on: October 25, 2014, 09:25:53 am »
where the hell did I write these classes are gzip?

I wrote that with the help of zlib and units from free pascal, you can do it. I even give a link to a pascal port of zlib (static linked) to avoid the need of shipping zlib library with your app.

http://www.ljr.ch/aa/GZfpc.zip
« Last Edit: October 25, 2014, 10:03:22 am by sam707 »

Chris95

  • Newbie
  • Posts: 4
Re: Decompress GZIP Stream
« Reply #10 on: October 25, 2014, 10:59:24 am »
@jarto Thank you very much!It's working great! :-*
If somebody else need it here is my code:

Code: [Select]
uses
  AbUnzper, AbUtils;
       
function DeCompressGZip(Stream : TStream): TMemoryStream;
var
  UnZipper : TAbUnZipper;
begin
  UnZipper := TAbUnZipper.Create(nil);
  try
    UnZipper.ForceType := True;
    UnZipper.ArchiveType := atGzip;
    UnZipper.Stream := Stream;
    Result := TMemoryStream.Create;
    UnZipper.ExtractToStream('', Result);
  finally
    FreeAndNil(UnZipper);
  end;
end;

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #11 on: October 25, 2014, 01:46:48 pm »
abbrevia latest release 2007 :D

if theres Gzip improvments someday dont count on non maintained packages

preferable solution is to use external libraries like zlib which are well updated excpt if you like to read and write files for Cleopatra Queen ;)

the archive in my last post is a fully console free pascal clone of gzip from 2003. It is 'static' and do not benefit of external libraries improvements.

anyway, whatever are your goals for archieving purpose, the copyrights around LZO/LZW/LZH where earlier a barrier that felt down in time and these LZ Familly of algorithms are much better than the deflate one used by gzip to avoid licensing...

LZW patent expired on June 20, 2003
« Last Edit: October 25, 2014, 02:12:02 pm by sam707 »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Decompress GZIP Stream
« Reply #12 on: October 25, 2014, 02:31:36 pm »
abbrevia latest release 2007 :D

abbrevia.png attachments shows that the repo has been updated in 2014 and the abbrevia_release show that the 5.2 version was released also in 2014. So your info is a bit outdated.
 
if theres Gzip improvments someday dont count on non maintained packages

preferable solution is to use external libraries like zlib which are well updated excpt if you like to read and write files for Cleopatra Queen ;)

actually there is no difference if both of them are not updated after 2007 it makes no sense to add one more requirement in your application if you can avoid it, to top it up there is no way you can debug or patch the abbrevia source you might not be as fortunate for the external library. So my advice would be if there is native source for an ability you want I would go with the native code even if I had to patch it than any external file especially on linux where everything is a package that might or might not be installed in all installations.

the archive in my last post is a fully console free pascal clone of gzip from 2003. It is 'static' and do not benefit of external libraries improvements.

anyway, whatever are your goals for archieving purpose, the copyrights around LZO/LZW/LZH where earlier a barrier that felt down in time and these LZ Familly of algorithms are much better than the deflate one used by gzip to avoid licensing...

LZW patent expired on June 20, 2003

Nice! Now we need some one knowledgeable enough to create a TStream descendant so it can be used easily.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

sam707

  • Guest
Re: Decompress GZIP Stream
« Reply #13 on: October 25, 2014, 03:43:45 pm »
you are right on dates taazz, sorry i watched an outdated link. obviously, I also saw something very interesting inside the synopse project :

a very fast LZ compression with no Huffman and InMemory abilities

please take a look at these links. It's all writen for delphi/fpc and could be helpful to make the TStream descendant you are talking about.

http://synopse.info/fossil/artifact/6e841c21a065b603493d26a3c69f84716d17e0c4

http://synopse.info/fossil/artifact/bd258ac1227fbcc51064e8bd21cb281bc1dc8ebf

I am actually working on a private Tcp Protocol and use a LZW algo, but I might change to synopse's one after benchmarking (I can't use asm crossplatform)
« Last Edit: October 25, 2014, 03:48:42 pm by sam707 »

 

TinyPortal © 2005-2018