Platforms to show: All Mac Windows Linux Cross-Platform

Back to GZipFileMBS class.

GZipFileMBS.Adler32(start as UInt32, data as string) as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates a 32bit Adler Checksum about a given string.

Set start to 0 for the first call.
Later you can pass the result as the new start value to add data to your checksum.

This function is part of the zlib library and given as a free utility function to this class.

GZipFileMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
The destructor.

There is no need to call this method except you want to free all resources of this object now without waiting for Xojo to do it for you.

GZipFileMBS.CloseForString as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Closes the file and returns the string.
Example
Function GZIPStringWriteMBS(data as string) As string
dim g as new GZipFileMBS

if g.CreateForString then
g.Write data

Return g.CloseForString
end if
End Function

Only for use with CreateForString function.
Returns empty string on any error.

Some examples using this method:

GZipFileMBS.CRC32(start as UInt32, data as string) as UInt32

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates a 32bit Checksum about a given string.

Set start to 0 for the first call.
Later you can pass the result as the new start value to add data to your checksum.

This function is part of the zlib library and given as a free utility function to this class.

GZipFileMBS.CreateForString as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new gzip file in memory.
Example
Function GZIPStringWriteMBS(data as string) As string
dim g as new GZipFileMBS

if g.CreateForString then
g.Write data

Return g.CloseForString
end if
End Function

Use with the CloseForString method to compress data in memory.
Returns false on any error and true on success.

GZipFileMBS.Flush(flush as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Flushes all pending output into the compressed file.

The parameter flush is as in the zlib deflate() function.
Lasterror is set.
Flush should be called only when strictly necessary because it can degrade compression.

GZipFileMBS.Open(file as folderitem, mode as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a gzip (.gz) file for reading or writing.

The mode parameter is as in fopen ("rb" read binary or "wb" for write binary) but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h".

Open can be used to read a file which is not in gzip format; in this case Read will directly read from the file without decompression.

Open returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR).

Returns false on any error and true on success.

GZipFileMBS.OpenString(data as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 9.6 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Opens a gzip (.gz) file for reading from a file.
Example
Function GZipStringReadMBS(compressedData as string) As string
dim g as new GZipFileMBS

const BlockSize=1000000

if g.OpenString(compressedData) then

dim parts(-1) as string

while not g.eof
dim s as string=g.Read(BlockSize)
parts.Append s
wend

Return Join(parts,"")
end if
End Function

Same as Open, but reading from the given string.

GZipFileMBS.Read(ByteCount as Int64) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the given number of bytes into a string.

Returns "" on any error.
May return less bytes than requested.
Lasterror is set.

GZipFileMBS.ReadByte as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads one byte from the file.

GZipFileMBS.ReadData(ByteCount as Int64) as Memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 15.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reads the given number of bytes into a memoryblock.

Returns nil on any error.
May return less bytes than requested.
Lasterror is set.

GZipFileMBS.Rewind

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Moves the file position for reading files to the file start.

Equal to: position=0

GZipFileMBS.SetParameter(level as Integer, strategy as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Dynamically update the compression level or strategy.

Lasterror is set.

Possible values:
FILTERED 1
HUFFMAN_ONLY 2
DEFAULT_STRATEGY 0

GZipFileMBS.Write(data as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 15.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes a Memoryblock to a file.

Lasterror is set.

See also:

GZipFileMBS.Write(data as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes a string to a file.

Note that encoding can make trouble as the raw bytes from the string are written.
Lasterror is set.

See also:

GZipFileMBS.WriteByte(data as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Compression MBS Compression Plugin 4.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Writes one byte to the file.

The items on this page are in the following plugins: MBS Compression Plugin.


The biggest plugin in space...