---
product: Chilkat
product_version: 11.7.0
language: activex
language_label: ActiveX
class: UnixCompress
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/xUnixCompressRef.html
---
# Chilkat UnixCompress — ActiveX — v11.7.0

> Chilkat 11.7.0 · language=activex · class=UnixCompress
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/UnixCompress.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/activex/guide.md`.

## Purpose

**Compress, uncompress, and unpack legacy UNIX `.Z` files.**

`Chilkat.UnixCompress` provides UNIX `compress` and `uncompress` functionality for legacy `.Z` files. It supports file-based, memory-based, and string-based workflows, uses LZW compression, can unpack `.tar.Z` archives, and includes abort and progress-related support for longer-running operations.

**Compress to .Z**

Compress files, memory data, or strings into UNIX `.Z` format using LZW compression.

**Uncompress .Z data**

Expand UNIX-compressed data back to files, memory, byte arrays, or text depending on the application workflow.

**File workflows**

Compress and uncompress directly between input and output files when working with existing filesystem data.

**Memory workflows**

Work with compressed or uncompressed byte data in memory when temporary files are not desired.

**String workflows**

Compress and uncompress text using an explicit character set so string data round-trips correctly.

**Unpack tar.Z archives**

Use `UnTarZ` to decompress and extract legacy `.tar.Z` archives in a single workflow.

**Common pattern:** Use `UnixCompress` when the data is in classic UNIX `.Z` format or when a `.tar.Z` archive must be unpacked. Use `Chilkat.Gzip` for `.gz` and `.tar.gz` files, `Chilkat.Bz2` for `.bz2` files, and `Chilkat.Compression` for raw compression algorithms and general-purpose compression workflows.

For an extended overview, see [UnixCompress Class Overview](https://www.chilkatsoft.com/unixcompress_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```clike
Note:
For a specific major version, use "Chilkat.UnixCompress.<major_version>", such as "Chilkat.UnixCompress.10" for Chilkat v10.*.*
See Chilkat ActiveX Object Creation

(ASP)
set obj = Server.CreateObject("Chilkat.UnixCompress")

(AutoIt)
$obj = ObjCreate("Chilkat.UnixCompress")

(Visual Basic 6.0)
Dim obj As New UnixCompress

(VBScript)
set obj = CreateObject("Chilkat.UnixCompress")

(VBA, such as Excel)
Dim obj As New UnixCompress
See How to Use ActiveX in Excel

(Delphi)
obj := TUnixCompress.Create(Self);

(FoxPro)
loObject = CreateObject('Chilkat.UnixCompress')

(Xbase++)
oObject := CreateObject("Chilkat.UnixCompress")

(PowerBuilder)
lole_object = create oleobject
li_rc = lole_object.ConnectToNewObject("Chilkat.UnixCompress")

(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.UnixCompress', @obj OUT

(Javascript)
var obj = new ActiveXObject("Chilkat.UnixCompress");
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in ActiveX.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `DebugLogFilePath As String` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `LastBinaryResult As Variant (read-only)` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `LastErrorHtml As String (read-only)` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `LastErrorText As String (read-only)` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `LastErrorXml As String (read-only)` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `LastMethodSuccess As Long` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `LastStringResult As String (read-only)` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `LastStringResultLen As Long (read-only)` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `VerboseLogging As Long` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `Version As String (read-only)` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `AbortCurrent As Long` |
| `HeartbeatMs` | property, read/write | `HeartbeatMs As Long` |
| `CompressFile` | method | `CompressFile(inFilename As String, destPath As String) As Long` |
| `CompressFileToMem` | method | `CompressFileToMem(inFilename As String) As Variant` |
| `CompressMemory` | method | `CompressMemory(inData As Variant) As Variant` |
| `CompressMemToFile` | method | `CompressMemToFile(inData As Variant, destPath As String) As Long` |
| `CompressString` | method | `CompressString(inStr As String, charset As String) As Variant` |
| `CompressStringToFile` | method | `CompressStringToFile(inStr As String, charset As String, destPath As String) As Long` |
| `LoadTaskCaller` | method | `LoadTaskCaller(task As ChilkatTask) As Long` |
| `ReadFile` | method | `ReadFile(filename As String) As Variant` |
| `UncompressFile` | method | `UncompressFile(inFilename As String, destPath As String) As Long` |
| `UncompressFileToMem` | method | `UncompressFileToMem(inFilename As String) As Variant` |
| `UncompressFileToString` | method | `UncompressFileToString(zFilename As String, charset As String) As String` |
| `UncompressMemory` | method | `UncompressMemory(inData As Variant) As Variant` |
| `UncompressMemToFile` | method | `UncompressMemToFile(inData As Variant, destPath As String) As Long` |
| `UncompressString` | method | `UncompressString(inCompressedData As Variant, charset As String) As String` |
| `UnTarZ` | method | `UnTarZ(zFilename As String, destDir As String, ByVal bNoAbsolute As Long) As Long` |
| `WriteFile` | method | `WriteFile(filename As String, binaryData As Variant) As Long` |

## Properties

### UnixCompress.AbortCurrent

`Chilkat 11.7.0 · activex · UnixCompress · AbortCurrent · property · read/write · since 9.5.0.58`

```
AbortCurrent As Long
```

When set to `1`, causes the currently running method to abort. Methods that always finish quickly (i.e.have no length file operations or network communications) are not affected. If no method is running, then this property is automatically reset to `0` when the next method is called. When the abort occurs, this property is reset to `0`. Both synchronous and asynchronous method calls can be aborted. (A synchronous method call could be aborted by setting this property from a separate thread.)

### UnixCompress.HeartbeatMs

`Chilkat 11.7.0 · activex · UnixCompress · HeartbeatMs · property · read/write`

```
HeartbeatMs As Long
```

**Full documentation for this property (same in every language):** [Event Callback Examples](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/event_callback_examples.md)

The interval in milliseconds between each `AbortCheck` event callback, which enables an application to abort certain method calls before they complete. **By default, HeartbeatMs is set to** `0`**, meaning no AbortCheck event callbacks will trigger.**

## Methods

### UnixCompress.CompressFile

`Chilkat 11.7.0 · activex · UnixCompress · CompressFile · method`

```
CompressFile(inFilename As String, destPath As String) As Long
```

Compresses a file to create a UNIX compressed file (.Z). This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.

Returns 1 for success, 0 for failure.

Async variant: `CompressFileAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.CompressFileToMem

`Chilkat 11.7.0 · activex · UnixCompress · CompressFileToMem · method`

```
CompressFileToMem(inFilename As String) As Variant
```

Unix compresses a file to an in-memory image of a .Z file. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

Async variant: `CompressFileToMemAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.CompressMemory

`Chilkat 11.7.0 · activex · UnixCompress · CompressMemory · method`

```
CompressMemory(inData As Variant) As Variant
```

Compresses in-memory data to an in-memory image of a .Z file. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### UnixCompress.CompressMemToFile

`Chilkat 11.7.0 · activex · UnixCompress · CompressMemToFile · method`

```
CompressMemToFile(inData As Variant, destPath As String) As Long
```

Unix compresses and creates a .Z file from in-memory data. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns 1 for success, 0 for failure.

### UnixCompress.CompressString

`Chilkat 11.7.0 · activex · UnixCompress · CompressString · method`

```
CompressString(inStr As String, charset As String) As Variant
```

**Full documentation for this method (same in every language):** [List of Valid Charsets](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

Compresses a string to an in-memory image of a .Z file. Prior to compression, the string is converted to the character encoding specified by `charset`. The `charset` can be any one of a large number of character encodings, such as `utf-8`, `iso-8859-1`, `Windows-1252`, `ucs-2`, etc.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### UnixCompress.CompressStringToFile

`Chilkat 11.7.0 · activex · UnixCompress · CompressStringToFile · method`

```
CompressStringToFile(inStr As String, charset As String, destPath As String) As Long
```

**Full documentation for this method (same in every language):** [List of Valid Charsets](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

Unix compresses and creates a .Z file from string data. The `charset` specifies the character encoding used for the byte representation of the characters when compressed. The `charset` can be any one of a large number of character encodings, such as `utf-8`, `iso-8859-1`, `Windows-1252`, `ucs-2`, etc.

Returns 1 for success, 0 for failure.

### UnixCompress.LoadTaskCaller

`Chilkat 11.7.0 · activex · UnixCompress · LoadTaskCaller · method · since 9.5.0.80`

```
LoadTaskCaller(task As ChilkatTask) As Long
```

Loads the caller of the task's async method.

Returns 1 for success, 0 for failure.

### UnixCompress.ReadFile

`Chilkat 11.7.0 · activex · UnixCompress · ReadFile · method`

```
ReadFile(filename As String) As Variant
```

Convenience method to read an entire file and return as a byte array.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### UnixCompress.UncompressFile

`Chilkat 11.7.0 · activex · UnixCompress · UncompressFile · method`

```
UncompressFile(inFilename As String, destPath As String) As Long
```

Uncompresses a .Z file. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns 1 for success, 0 for failure.

Async variant: `UncompressFileAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.UncompressFileToMem

`Chilkat 11.7.0 · activex · UnixCompress · UncompressFileToMem · method`

```
UncompressFileToMem(inFilename As String) As Variant
```

Uncompresses a .Z file directly to memory. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

Async variant: `UncompressFileToMemAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.UncompressFileToString

`Chilkat 11.7.0 · activex · UnixCompress · UncompressFileToString · method`

```
UncompressFileToString(zFilename As String, charset As String) As String
```

**Full documentation for this method (same in every language):** [List of Valid Charsets](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

Uncompresses a .Z file that contains a text file. The contents of the text file are returned as a string. The character encoding of the text file is specified by `charset`. Typical charsets are `iso-8859-1`, `utf-8`, `windows-1252`, `shift_JIS`, `big5`, etc.

Returns `Nothing` on failure

Async variant: `UncompressFileToStringAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.UncompressMemory

`Chilkat 11.7.0 · activex · UnixCompress · UncompressMemory · method`

```
UncompressMemory(inData As Variant) As Variant
```

Uncompresses from an in-memory image of a .Z file directly into memory. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### UnixCompress.UncompressMemToFile

`Chilkat 11.7.0 · activex · UnixCompress · UncompressMemToFile · method`

```
UncompressMemToFile(inData As Variant, destPath As String) As Long
```

Uncompresses from an in-memory image of a .Z file to a file. (This compression uses the LZW (Lempel-Ziv-Welch) compression algorithm.)

Returns 1 for success, 0 for failure.

### UnixCompress.UncompressString

`Chilkat 11.7.0 · activex · UnixCompress · UncompressString · method`

```
UncompressString(inCompressedData As Variant, charset As String) As String
```

**Full documentation for this method (same in every language):** [List of Valid Charsets](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

Uncompresses from an in-memory image of a .Z file directly to a string. The `charset` specifies the character encoding used to interpret the bytes resulting from the decompression. The `charset` can be any one of a large number of character encodings, such as `utf-8`, `iso-8859-1`, `Windows-1252`, `ucs-2`, etc.

Returns `Nothing` on failure

### UnixCompress.UnTarZ

`Chilkat 11.7.0 · activex · UnixCompress · UnTarZ · method`

```
UnTarZ(zFilename As String, destDir As String, ByVal bNoAbsolute As Long) As Long
```

Unpacks a .tar.Z file. The decompress and untar occur in streaming mode. There are no temporary files and the memory footprint is constant (and small) while untarring.

Returns 1 for success, 0 for failure.

Async variant: `UnTarZAsync` — same arguments, returns a `Task` (see Async variants below).

### UnixCompress.WriteFile

`Chilkat 11.7.0 · activex · UnixCompress · WriteFile · method`

```
WriteFile(filename As String, binaryData As Variant) As Long
```

Convenience method for writing the contents of a byte array to a file.

Returns 1 for success, 0 for failure.

## Events and callbacks

### UnixCompress.AbortCheck (event)

`Chilkat 11.7.0 · activex · UnixCompress · AbortCheck · event`

```
AbortCheck(abort As Long)
```

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the `HeartbeatMs` property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

**VB6 Event callback implementation:**

**Important:** Event callbacks from ***asynchronous method calls*** are generally not possible from the ActiveX. See [VB6 Event Callbacks](https://www.chilkatsoft.com/vb6_event_callbacks.asp)

```vb
Dim WithEvents myUnixcompress As UnixCompress

Private Sub myUnixcompress_AbortCheck(abort As Long)

	'Insert application code here.

End Sub
```

### UnixCompress.PercentDone (event)

`Chilkat 11.7.0 · activex · UnixCompress · PercentDone · event`

```
PercentDone(ByVal pctDone As Long, abort As Long)
```

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The `pctDone` argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have `pctDone` equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an `AbortCheck` event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the `abort` output argument to `1`. This will cause the method to terminate and return a failure status or corresponding failure value.

**VB6 Event callback implementation:**

**Important:** Event callbacks from ***asynchronous method calls*** are generally not possible from the ActiveX. See [VB6 Event Callbacks](https://www.chilkatsoft.com/vb6_event_callbacks.asp)

```vb
Dim WithEvents myUnixcompress As UnixCompress

Private Sub myUnixcompress_PercentDone(ByVal pctDone As Long, abort As Long)

	'Insert application code here.

End Sub
```

### UnixCompress.ProgressInfo (event)

`Chilkat 11.7.0 · activex · UnixCompress · ProgressInfo · event`

```
ProgressInfo(ByVal name As String, ByVal value As String)
```

This event callback provides `tag name`/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

**VB6 Event callback implementation:**

**Important:** Event callbacks from ***asynchronous method calls*** are generally not possible from the ActiveX. See [VB6 Event Callbacks](https://www.chilkatsoft.com/vb6_event_callbacks.asp)

```vb
Dim WithEvents myUnixcompress As UnixCompress

Private Sub myUnixcompress_ProgressInfo(ByVal name As String, ByVal value As String)

	'Insert application code here.

End Sub
```

### UnixCompress.TaskCompleted (event)

`Chilkat 11.7.0 · activex · UnixCompress · TaskCompleted · event`

```
TaskCompleted(task As ChilkatTask)
```

Called from the background thread when an asynchronous task completes.

**VB6 Event callback implementation:**

**Important:** Event callbacks from ***asynchronous method calls*** are generally not possible from the ActiveX. See [VB6 Event Callbacks](https://www.chilkatsoft.com/vb6_event_callbacks.asp)

```vb
Dim WithEvents myUnixcompress As UnixCompress

Private Sub myUnixcompress_TaskCompleted(task As ChilkatTask)

	'Insert application code here.

End Sub
```

## Async variants

Each returns a `Task` instead of the result and takes the same arguments as the synchronous method; run the task, wait for `Finished`, then read the result from the task. No new Async methods are added from 11.7.0 on.

```
CompressFileAsync(inFilename As String, destPath As String) As ChilkatTask
CompressFileToMemAsync(inFilename As String) As ChilkatTask
UncompressFileAsync(inFilename As String, destPath As String) As ChilkatTask
UncompressFileToMemAsync(inFilename As String) As ChilkatTask
UncompressFileToStringAsync(zFilename As String, charset As String) As ChilkatTask
UnTarZAsync(zFilename As String, destDir As String, ByVal bNoAbsolute As Long) As ChilkatTask
```

## Related classes

[`Task`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/activex/classes/Task.md)

