For example, creating an in-memory compression stream from a zero-length MemoryBlock and writing a string to it:ĭim f As FolderItem = GetOpenFolderItem( '' ) ' the bzip file to open Dim data As MemoryBlock = BZip2.Decompress(f) If data Nil Then MsgBox( 'Decompression succeeded!' ) Else MsgBox( 'Decompression failed!' ) End If How to incorporate bzip2 into your Realbasic/Xojo project Import the BZip2 module Instances of BZ2Stream can be created from MemoryBlocks, FolderItems, and objects that implement the Readable and/or Writeable interfaces. Anything written to a BZ2Stream is compressed and emitted to the output stream (another Writeable) reading from a BZ2Stream decompresses data from the input stream (another Readable). The BZ2Stream is a BinaryStream work-alike, and implements both the Readable and Writeable interfaces. The second way to use BZip2 is with the BZ2Stream class. Refer to the examples below for demonstrations of some of these functions. Methods which do not have a Destination parameter return output as a MemoryBlock instead. Where source is a MemoryBlock, FolderItem, or an object which implements the Readable interface and destination (when provided) is a FolderItem or an object which implements the Writeable interface.
Function (source, options ) As MemoryBlock