---
product: Chilkat
product_version: 11.7.0
language: delphidll
language_label: Delphi DLL
class: UnixCompress
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/dd_CkUnixCompressRef.html
---
# Chilkat UnixCompress — Delphi DLL — v11.7.0

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

**Create/Dispose**

```pascal
var
myObject: HCkUnixCompress;

begin
myObject := CkUnixCompress_Create();

// ...

CkUnixCompress_Dispose(myObject);
end;
```

`function CkUnixCompress_Create: HCkUnixCompress; stdcall;`

Creates an instance of the HCkUnixCompress object and returns a handle (i.e. a Pointer). The handle is passed in the 1st argument for the functions listed on this page.

`procedure CkUnixCompress_Dispose(handle: HCkUnixCompress); stdcall;`

Objects created by calling CkUnixCompress_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

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 Delphi DLL.

## 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` | `procedure CkUnixCompress_getDebugLogFilePath(objHandle: HCkUnixCompress; outPropVal: HCkString); stdcall; procedure CkUnixCompress_putDebugLogFilePath(objHandle: HCkUnixCompress; newPropVal: PWideChar); stdcall; function CkUnixCompress__debugLogFilePath(objHandle: HCkUnixCompress): PWideChar; stdcall;` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `procedure CkUnixCompress_getLastErrorHtml(objHandle: HCkUnixCompress; outPropVal: HCkString); stdcall; function CkUnixCompress__lastErrorHtml(objHandle: HCkUnixCompress): PWideChar; stdcall;` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `procedure CkUnixCompress_getLastErrorText(objHandle: HCkUnixCompress; outPropVal: HCkString); stdcall; function CkUnixCompress__lastErrorText(objHandle: HCkUnixCompress): PWideChar; stdcall;` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `procedure CkUnixCompress_getLastErrorXml(objHandle: HCkUnixCompress; outPropVal: HCkString); stdcall; function CkUnixCompress__lastErrorXml(objHandle: HCkUnixCompress): PWideChar; stdcall;` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `function CkUnixCompress_getLastMethodSuccess(objHandle: HCkUnixCompress): wordbool; stdcall; procedure CkUnixCompress_putLastMethodSuccess(objHandle: HCkUnixCompress; newPropVal: wordbool); stdcall;` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `VerboseLogging` | `function CkUnixCompress_getVerboseLogging(objHandle: HCkUnixCompress): wordbool; stdcall; procedure CkUnixCompress_putVerboseLogging(objHandle: HCkUnixCompress; newPropVal: wordbool); stdcall;` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `procedure CkUnixCompress_getVersion(objHandle: HCkUnixCompress; outPropVal: HCkString); stdcall; function CkUnixCompress__version(objHandle: HCkUnixCompress): PWideChar; stdcall;` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `function CkUnixCompress_getAbortCurrent(objHandle: HCkUnixCompress): wordbool; stdcall; procedure CkUnixCompress_putAbortCurrent(objHandle: HCkUnixCompress; newPropVal: wordbool); stdcall;` |
| `HeartbeatMs` | property, read/write | `function CkUnixCompress_getHeartbeatMs(objHandle: HCkUnixCompress): Integer; stdcall; procedure CkUnixCompress_putHeartbeatMs(objHandle: HCkUnixCompress; newPropVal: Integer); stdcall;` |
| `CompressFile` | method | `function CkUnixCompress_CompressFile(objHandle: HCkUnixCompress;     inFilename: PWideChar;     destPath: PWideChar): wordbool; stdcall;` |
| `CompressStringToFile` | method | `function CkUnixCompress_CompressStringToFile(objHandle: HCkUnixCompress;     inStr: PWideChar;     charset: PWideChar;     destPath: PWideChar): wordbool; stdcall;` |
| `LoadTaskCaller` | method | `function CkUnixCompress_LoadTaskCaller(objHandle: HCkUnixCompress;     task: HCkTask): wordbool; stdcall;` |
| `UncompressFile` | method | `function CkUnixCompress_UncompressFile(objHandle: HCkUnixCompress;     inFilename: PWideChar;     destPath: PWideChar): wordbool; stdcall;` |
| `UncompressFileToString` | method | `function CkUnixCompress_UncompressFileToString(objHandle: HCkUnixCompress;     zFilename: PWideChar;     charset: PWideChar;     outStr: HCkString): wordbool; stdcall; function CkUnixCompress__uncompressFileToString(objHandle: HCkUnixCompress;     zFilename: PWideChar;     charset: PWideChar): PWideChar; stdcall;` |
| `UnTarZ` | method | `function CkUnixCompress_UnTarZ(objHandle: HCkUnixCompress;     zFilename: PWideChar;     destDir: PWideChar;     bNoAbsolute: wordbool): wordbool; stdcall;` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### UnixCompress.AbortCurrent

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

```pascal
function CkUnixCompress_getAbortCurrent(objHandle: HCkUnixCompress): wordbool; stdcall;
procedure CkUnixCompress_putAbortCurrent(objHandle: HCkUnixCompress; newPropVal: wordbool); stdcall;
```

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

### UnixCompress.HeartbeatMs

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

```pascal
function CkUnixCompress_getHeartbeatMs(objHandle: HCkUnixCompress): Integer; stdcall;
procedure CkUnixCompress_putHeartbeatMs(objHandle: HCkUnixCompress; newPropVal: Integer); stdcall;
```

**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 · delphidll · UnixCompress · CompressFile · method`

```pascal
function CkUnixCompress_CompressFile(objHandle: HCkUnixCompress;
    inFilename: PWideChar;
    destPath: PWideChar): wordbool; stdcall;
```

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

`Chilkat 11.7.0 · delphidll · UnixCompress · CompressStringToFile · method`

```pascal
function CkUnixCompress_CompressStringToFile(objHandle: HCkUnixCompress;
    inStr: PWideChar;
    charset: PWideChar;
    destPath: PWideChar): wordbool; stdcall;
```

**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 · delphidll · UnixCompress · LoadTaskCaller · method · since 9.5.0.80`

```pascal
function CkUnixCompress_LoadTaskCaller(objHandle: HCkUnixCompress;
    task: HCkTask): wordbool; stdcall;
```

Loads the caller of the task's async method.

Returns True for success, False for failure.

### UnixCompress.UncompressFile

`Chilkat 11.7.0 · delphidll · UnixCompress · UncompressFile · method`

```pascal
function CkUnixCompress_UncompressFile(objHandle: HCkUnixCompress;
    inFilename: PWideChar;
    destPath: PWideChar): wordbool; stdcall;
```

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

`Chilkat 11.7.0 · delphidll · UnixCompress · UncompressFileToString · method`

```pascal
function CkUnixCompress_UncompressFileToString(objHandle: HCkUnixCompress;
    zFilename: PWideChar;
    charset: PWideChar;
    outStr: HCkString): wordbool; stdcall;
function CkUnixCompress__uncompressFileToString(objHandle: HCkUnixCompress;
    zFilename: PWideChar;
    charset: PWideChar): PWideChar; stdcall;
```

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

See the notes about [PWideChar memory ownership and validity](https://www.chilkatsoft.com/delphi_pwidechar.asp).

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

### UnixCompress.UnTarZ

`Chilkat 11.7.0 · delphidll · UnixCompress · UnTarZ · method`

```pascal
function CkUnixCompress_UnTarZ(objHandle: HCkUnixCompress;
    zFilename: PWideChar;
    destDir: PWideChar;
    bNoAbsolute: wordbool): wordbool; stdcall;
```

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

## Events and callbacks

### UnixCompress.AbortCheck (event)

`Chilkat 11.7.0 · delphidll · UnixCompress · AbortCheck · event`

```pascal
function MyAbortCheck(): Integer; cdecl;
```

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. Return `True` to abort; return `False` to continue (not abort)

### UnixCompress.PercentDone (event)

`Chilkat 11.7.0 · delphidll · UnixCompress · PercentDone · event`

```pascal
function MyPercentDone(pctDone: Integer): Integer; cdecl;
```

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.

Return `True` to abort; return `False` to continue (not abort)

### UnixCompress.ProgressInfo (event)

`Chilkat 11.7.0 · delphidll · UnixCompress · ProgressInfo · event`

```pascal
procedure MyProgressInfo(name: PWideChar; value: PWideChar) cdecl;
```

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.

### UnixCompress.TaskCompleted (event)

`Chilkat 11.7.0 · delphidll · UnixCompress · TaskCompleted · event`

```pascal
procedure MyTaskCompleted(task: HCkTask) cdecl;
```

Called from the background thread when an asynchronous task completes.

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

```pascal
function CkUnixCompress_CompressFileAsync(objHandle: HCkUnixCompress;
    inFilename: PWideChar;
    destPath: PWideChar): HCkTask; stdcall;
function CkUnixCompress_UncompressFileAsync(objHandle: HCkUnixCompress;
    inFilename: PWideChar;
    destPath: PWideChar): HCkTask; stdcall;
function CkUnixCompress_UncompressFileToStringAsync(objHandle: HCkUnixCompress;
    zFilename: PWideChar;
    charset: PWideChar): HCkTask; stdcall;
function CkUnixCompress_UnTarZAsync(objHandle: HCkUnixCompress;
    zFilename: PWideChar;
    destDir: PWideChar;
    bNoAbsolute: wordbool): HCkTask; stdcall;
```

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `CompressFileToMem` | method | before 11.6.1 | — |
| `CompressMemory` | method | before 11.6.1 | — |
| `CompressMemToFile` | method | before 11.6.1 | — |
| `CompressString` | method | before 11.6.1 | — |
| `UncompressFileToMem` | method | before 11.6.1 | — |
| `UncompressMemory` | method | before 11.6.1 | — |
| `UncompressMemToFile` | method | before 11.6.1 | — |
| `UncompressString` | method | before 11.6.1 | — |

## Related classes

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

