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

> Chilkat 11.7.0 · language=dataflex · 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/dataflex/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**

```dataflex
// (Dataflex programs use the 32-bit Chilkat ActiveX)
Handle hoUnixCompress
Get Create(RefClass(cComUnixCompress)) to hoUnixCompress
```

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 DataFlex.

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` | `Function ComDebugLogFilePath Returns String Procedure Set ComDebugLogFilePath String value` | 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` | `Function ComLastBinaryResult Returns Variant` | 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` | `Function ComLastErrorHtml Returns String` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `Function ComLastErrorText Returns String` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `Function ComLastErrorXml Returns String` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `Function ComLastMethodSuccess Returns Boolean Procedure Set ComLastMethodSuccess Boolean value` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `LastStringResult` | `Function ComLastStringResult Returns String` | 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` | `Function ComLastStringResultLen Returns Integer` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `Function ComVerboseLogging Returns Boolean Procedure Set ComVerboseLogging Boolean value` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `Function ComVersion Returns String` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `Function ComAbortCurrent Returns Boolean Procedure Set ComAbortCurrent Boolean value` |
| `CompressFile` | method | `Function ComCompressFile String inFilename String destPath Returns Boolean` |
| `CompressFileToMem` | method | `Function ComCompressFileToMem String inFilename Returns Variant` |
| `CompressMemory` | method | `Function ComCompressMemory Variant inData Returns Variant` |
| `CompressMemToFile` | method | `Function ComCompressMemToFile Variant inData String destPath Returns Boolean` |
| `CompressString` | method | `Function ComCompressString String inStr String charset Returns Variant` |
| `CompressStringToFile` | method | `Function ComCompressStringToFile String inStr String charset String destPath Returns Boolean` |
| `LoadTaskCaller` | method | `Function ComLoadTaskCaller cComChilkatTask task Returns Boolean` |
| `ReadFile` | method | `Function ComReadFile String filename Returns Variant` |
| `UncompressFile` | method | `Function ComUncompressFile String inFilename String destPath Returns Boolean` |
| `UncompressFileToMem` | method | `Function ComUncompressFileToMem String inFilename Returns Variant` |
| `UncompressFileToString` | method | `Function ComUncompressFileToString String zFilename String charset Returns String` |
| `UncompressMemory` | method | `Function ComUncompressMemory Variant inData Returns Variant` |
| `UncompressMemToFile` | method | `Function ComUncompressMemToFile Variant inData String destPath Returns Boolean` |
| `UncompressString` | method | `Function ComUncompressString Variant inCompressedData String charset Returns String` |
| `UnTarZ` | method | `Function ComUnTarZ String zFilename String destDir Boolean bNoAbsolute Returns Boolean` |
| `WriteFile` | method | `Function ComWriteFile String filename Variant binaryData Returns Boolean` |

## Properties

### UnixCompress.AbortCurrent

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

```dataflex
Function ComAbortCurrent Returns Boolean
Procedure Set ComAbortCurrent Boolean value
```

When set to `True`, 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 `False` when the next method is called. When the abort occurs, this property is reset to `False`. Both synchronous and asynchronous method calls can be aborted. (A synchronous method call could be aborted by setting this property from a separate thread.)

## Methods

### UnixCompress.CompressFile

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressFile · method`

```dataflex
Function ComCompressFile String inFilename String destPath Returns Boolean
```

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

Returns True for success, False for failure.

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

### UnixCompress.CompressFileToMem

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressFileToMem · method`

```dataflex
Function ComCompressFileToMem String inFilename Returns 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 `null` on failure

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

### UnixCompress.CompressMemory

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressMemory · method`

```dataflex
Function ComCompressMemory Variant inData Returns 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 `null` on failure

### UnixCompress.CompressMemToFile

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressMemToFile · method`

```dataflex
Function ComCompressMemToFile Variant inData String destPath Returns Boolean
```

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

Returns True for success, False for failure.

### UnixCompress.CompressString

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressString · method`

```dataflex
Function ComCompressString String inStr String charset Returns 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 `null` on failure

### UnixCompress.CompressStringToFile

`Chilkat 11.7.0 · dataflex · UnixCompress · CompressStringToFile · method`

```dataflex
Function ComCompressStringToFile String inStr String charset String destPath Returns Boolean
```

**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 True for success, False for failure.

### UnixCompress.LoadTaskCaller

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

```dataflex
Function ComLoadTaskCaller cComChilkatTask task Returns Boolean
```

Loads the caller of the task's async method.

Returns True for success, False for failure.

### UnixCompress.ReadFile

`Chilkat 11.7.0 · dataflex · UnixCompress · ReadFile · method`

```dataflex
Function ComReadFile String filename Returns Variant
```

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

Returns `null` on failure

### UnixCompress.UncompressFile

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressFile · method`

```dataflex
Function ComUncompressFile String inFilename String destPath Returns Boolean
```

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

Returns True for success, False for failure.

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

### UnixCompress.UncompressFileToMem

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressFileToMem · method`

```dataflex
Function ComUncompressFileToMem String inFilename Returns Variant
```

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

Returns `null` on failure

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

### UnixCompress.UncompressFileToString

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressFileToString · method`

```dataflex
Function ComUncompressFileToString String zFilename String charset Returns 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 `null` on failure

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

### UnixCompress.UncompressMemory

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressMemory · method`

```dataflex
Function ComUncompressMemory Variant inData Returns 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 `null` on failure

### UnixCompress.UncompressMemToFile

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressMemToFile · method`

```dataflex
Function ComUncompressMemToFile Variant inData String destPath Returns Boolean
```

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

Returns True for success, False for failure.

### UnixCompress.UncompressString

`Chilkat 11.7.0 · dataflex · UnixCompress · UncompressString · method`

```dataflex
Function ComUncompressString Variant inCompressedData String charset Returns 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 `null` on failure

### UnixCompress.UnTarZ

`Chilkat 11.7.0 · dataflex · UnixCompress · UnTarZ · method`

```dataflex
Function ComUnTarZ String zFilename String destDir Boolean bNoAbsolute Returns Boolean
```

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 True for success, False for failure.

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

### UnixCompress.WriteFile

`Chilkat 11.7.0 · dataflex · UnixCompress · WriteFile · method`

```dataflex
Function ComWriteFile String filename Variant binaryData Returns Boolean
```

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

Returns True for success, False for failure.

## Events and callbacks

This binding has no event callbacks. For progress, percent-done or cancellation use the `*Async` variant of a method and poll the returned `Task` (`PercentDone`, `Finished`, `Cancel`).

## 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.

```dataflex
Function ComCompressFileAsync String inFilename String destPath Returns cComChilkatTask
Function ComCompressFileToMemAsync String inFilename Returns cComChilkatTask
Function ComUncompressFileAsync String inFilename String destPath Returns cComChilkatTask
Function ComUncompressFileToMemAsync String inFilename Returns cComChilkatTask
Function ComUncompressFileToStringAsync String zFilename String charset Returns cComChilkatTask
Function ComUnTarZAsync String zFilename String destDir Boolean bNoAbsolute Returns cComChilkatTask
```

## Related classes

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

