gunzip without a file

  1. 5 years ago

    Will S

    4 May 2014 Santa Cruz 

    Hi all, my web page parsing program stopped working today because they started gzipping their content. I use the PageReceived event and my fix for now is to write it out to a file, gunzip and read back in; but I'd rather not have to go out through a file. Is that possible? The man pages say it'll process standard input to standard output but I don't know how to use those, and maybe I'm misreading :) (for mac if that makes a difference)

    This is the current file round-tripping. If I have to use this is it sound?

    Sub PageReceived(..., content as string)
    
      //content is gzipped
      dim f As FolderItem = SpecialFolder.Temporary.Child("agcontent.gz")
      dim bs As BinaryStream = BinaryStream.Create(f, true)
      bs.Write(content)
      bs.close
      bs = nil
    
      dim sh As new Shell
      sh.Execute("gunzip " + f.ShellPath)
      sh = nil
    
      f = SpecialFolder.Temporary.Child("agcontent")
      bs = BinaryStream.Open(f)
      content = bs.Read(bs.Length, Encodings.UTF8)
      bs.close
      bs = nil
      f.Delete
      f = nil
      
      //content now html, parse as before
      //...
    
    End Sub

    Thomas Templeman has cream, I mean code for this.

  2. Sam R

    4 May 2014 Pre-Release Testers, Xojo Pro Answer Hengchun, Pingtung, Taiwan

    Thomas Templeman has cream, I mean code for this.

  3. Jeremy C

    4 May 2014 Pre-Release Testers, Xojo Pro Ohio, USA

    Xojo actually has built in gzip, gunzip methods that work on memory or files. They are private and have changed over the course of time. Seems a shame to have the functionality already in the standard library but not be able to use it.

    Feedback Case #20404

    In the mean time, I found somewhere, should have recorded, a gzip library. It's declares around the gzip library. If you're interested, I'll put it up somewhere for you to grab.

  4. Will S

    4 May 2014 Santa Cruz 

    Thanks guys. What a rabbit hole. I don't really much at all understand how gzip, zlib, command line and declaring all work together. From a snippet posted by Eli Ott a couple weeks ago I think the declare lib would be "libz.dylib". There's actually 4 libz.*.dylib files in my ~usr/lib/ folder. Then it would be translating this code which I very tentatively think maybe I follow. Looks like a lot of work.

    In terminal I was able to get gzip compressing standard input to a file
    $ gzip > test.gz [return]
    apples [return][control-d]
    $

    and then decompress the file to standard output
    $ gzip -c -d test.gz [return]
    apples
    $

    Doing them together seems to be prohibited: "If no files are specified, gzip will compress from standard input, OR decompress to standard output."

    So now I look for Thomas Tempelmanns code... voila . ZLibInflator.Inflate look like the lot-of-work :) Will work it tomorrow, very tired. I use Thomas' global hotkey code too, need to keep these links handier.

  5. Mattias S

    5 May 2014 Pre-Release Testers, Xojo Pro Europe (Sweden, Stockholm)

    I have been using MBS Compression plug-in and the in-memory decompression for many years and it has saved me hours and hours of work. It works with zip and gz.

  6. Christian S

    5 May 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    We have UnzipMBS and GZipFileMBS classes in MBS Plugin and they work in memory only if you like.

  7. John H

    5 May 2014 Pre-Release Testers Planet earth

    @Jeremy C Xojo actually has built in gzip, gunzip methods that work on memory or files. They are private and have changed over the course of time. Seems a shame to have the functionality already in the standard library but not be able to use it.

    Feedback Case #20404

    In the mean time, I found somewhere, should have recorded, a gzip library. It's declares around the gzip library. If you're interested, I'll put it up somewhere for you to grab.

    in Feedback 19807 you find an example how to use the internal RS lib. but Xojo advise not to use it.

    Xojo/RS recommend not to use this code below

    //---------
    // Example how to use Xojo's internal Gzip
    //Compress String with _GzipString:
    //---------
    Dim s As String = "Uncompressed String" 
    Dim s1 As String 
    
    Dim GzipString As new _GzipString
    
    //Compressed String
    s1 = GzipString.Compress(s)
    ---------
  8. Jeremy C

    5 May 2014 Pre-Release Testers, Xojo Pro Ohio, USA

    @John H in Feedback 19807 you find an example how to use the internal RS lib. but Xojo advise not to use it.

    Xojo/RS recommend not to use this code below

    Right, because they have not declared the API stable. That is what Feedback Case #20404 is for. It asks Xojo to solidify the API and make it public. Then it would be recommended.

or Sign Up to reply!