RB-zlib

Fork me on GitHub

RB-zlib is a zlib binding for Realbasic and Xojo projects. It is designed and tested on Windows 7.

Download Source(zip) | Documentation | Issue Tracker

License:zlib license Language: RealBasic
 

This project wraps zlib in an object-oriented, event-driven, Xojo-flavored syntax.

This example compresses and decompresses a string in memory:

This example gzips a file:

  Dim f As FolderItem = GetSaveFolderItem("") ' a file to be gzipped
  If f <> Nil Then
    Dim bs As BinaryStream = BinaryStream.Open(f)
    Dim g As FolderItem = f.Parent.Child(f.Name + ".gz")
    Dim gz As zlib.GZStream = zlib.GZStream.Create(g)
    gz.Level = 9 ' set the compression level as desired
    While Not bs.EOF
      gz.Write(bs.Read(1024))
    Wend
    bs.Close
    gz.Close
  End If

This example opens an existing gzip file and decompresses it into a `MemoryBlock`:

  Dim f As FolderItem = GetOpenFolderItem("") ' the gzip file to open
  If f <> Nil Then
    Dim gz As zlib.GZStream = zlib.GZStream.Open(f)
    Dim uncompressed As New MemoryBlock(0)
    Dim bs As BinaryStream = New BinaryStream(uncompressed)
    While Not gz.EOF
      bs.Write(gz.Read(1024))
    Wend
    bs.Close
    gz.Close
  End If

Refer to the documentation for additional examples and exposition.