---
product: Chilkat
product_version: 11.7.0
language: ckruby
language_label: Ruby
class: Tar
class_name: CkTar
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/rubyCkTarRef.html
---
# Chilkat Tar — Ruby — v11.7.0

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

## Purpose

**Create, list, verify, filter, and extract TAR archives and compressed TAR formats.**

`Chilkat.Tar` creates, verifies, lists, and extracts TAR archives, including compressed TAR formats such as `.tar.gz`, `.tgz`, `.tar.bz2`, and `.tar.Z`. It supports adding individual files and directory trees, controlling archive paths, preserving or overriding file permissions, filtering included or extracted files, extracting from memory, extracting selected entries to memory or `BinData`, producing XML listings, and creating Debian `.deb` package archives from control and data tarballs.

**Create TAR archives**

Add files or directory trees and write standard TAR output, with control over archive paths, directory handling, and write format.

**Compressed TAR formats**

Work with common compressed archive forms such as `.tar.gz`, `.tgz`, `.tar.bz2`, and `.tar.Z`.

**List and verify contents**

Inspect archive entries, verify archive structure, and produce XML listings for display, logging, or programmatic processing.

**Selective extraction**

Extract entire archives or selected entries, including workflows that extract matching files directly to memory or `BinData`.

**Filters and paths**

Include or exclude files using filters, control relative paths in the archive, and manage how entries are restored during extraction.

**Permissions and packages**

Preserve or override UNIX-style permissions and create Debian `.deb` package archives from control and data tarballs.

**Common pattern:** Use `Tar` when the data is a TAR archive or a compressed TAR archive. Configure the archive paths, filters, permissions, and compression format, then create, list, verify, or extract the archive as needed. Use `Chilkat.Zip` for ZIP archives, `Chilkat.Gzip` for a single GZIP stream, and `Chilkat.Compression` for raw compression operations.

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

## Object creation, unlocking and error handling

**Object Creation**

```ruby
obj = Chilkat::CkTar.new()
```

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

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` | `# strVal is a string # ckStr is a CkString tar.get_DebugLogFilePath(ckStr); strVal = tar.debugLogFilePath(); tar.put_DebugLogFilePath(strVal);` | 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` | `# strVal is a string # ckStr is a CkString tar.get_LastErrorHtml(ckStr); strVal = tar.lastErrorHtml();` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `# strVal is a string # ckStr is a CkString tar.get_LastErrorText(ckStr); strVal = tar.lastErrorText();` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `# strVal is a string # ckStr is a CkString tar.get_LastErrorXml(ckStr); strVal = tar.lastErrorXml();` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `# boolVal is a boolean boolVal = tar.get_LastMethodSuccess(); tar.put_LastMethodSuccess(boolVal);` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `Utf8` | `# boolVal is a boolean boolVal = tar.get_Utf8(); tar.put_Utf8(boolVal);` | read/write | When set to `true`, all `string` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `# boolVal is a boolean boolVal = tar.get_VerboseLogging(); tar.put_VerboseLogging(boolVal);` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `# strVal is a string # ckStr is a CkString tar.get_Version(ckStr); strVal = tar.version();` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `CaptureXmlListing` | property, read/write | `# boolVal is a boolean boolVal = tar.get_CaptureXmlListing(); tar.put_CaptureXmlListing(boolVal);` |
| `Charset` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_Charset(ckStr); strVal = tar.charset(); tar.put_Charset(strVal);` |
| `DirMode` | property, read/write | `# intVal is an integer intVal = tar.get_DirMode(); tar.put_DirMode(intVal);` |
| `DirPrefix` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_DirPrefix(ckStr); strVal = tar.dirPrefix(); tar.put_DirPrefix(strVal);` |
| `FileMode` | property, read/write | `# intVal is an integer intVal = tar.get_FileMode(); tar.put_FileMode(intVal);` |
| `GroupId` | property, read/write | `# intVal is an integer intVal = tar.get_GroupId(); tar.put_GroupId(intVal);` |
| `GroupName` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_GroupName(ckStr); strVal = tar.groupName(); tar.put_GroupName(strVal);` |
| `MatchCaseSensitive` | property, read/write | `# boolVal is a boolean boolVal = tar.get_MatchCaseSensitive(); tar.put_MatchCaseSensitive(boolVal);` |
| `MustMatch` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_MustMatch(ckStr); strVal = tar.mustMatch(); tar.put_MustMatch(strVal);` |
| `MustNotMatch` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_MustNotMatch(ckStr); strVal = tar.mustNotMatch(); tar.put_MustNotMatch(strVal);` |
| `NoAbsolutePaths` | property, read/write | `# boolVal is a boolean boolVal = tar.get_NoAbsolutePaths(); tar.put_NoAbsolutePaths(boolVal);` |
| `NumDirRoots` | property, read-only | `# intVal is an integer intVal = tar.get_NumDirRoots();` |
| `ScriptFileMode` | property, read/write | `# intVal is an integer intVal = tar.get_ScriptFileMode(); tar.put_ScriptFileMode(intVal);` |
| `SuppressOutput` | property, read/write | `# boolVal is a boolean boolVal = tar.get_SuppressOutput(); tar.put_SuppressOutput(boolVal);` |
| `UntarCaseSensitive` | property, read/write | `# boolVal is a boolean boolVal = tar.get_UntarCaseSensitive(); tar.put_UntarCaseSensitive(boolVal);` |
| `UntarDebugLog` | property, read/write | `# boolVal is a boolean boolVal = tar.get_UntarDebugLog(); tar.put_UntarDebugLog(boolVal);` |
| `UntarDiscardPaths` | property, read/write | `# boolVal is a boolean boolVal = tar.get_UntarDiscardPaths(); tar.put_UntarDiscardPaths(boolVal);` |
| `UntarFromDir` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_UntarFromDir(ckStr); strVal = tar.untarFromDir(); tar.put_UntarFromDir(strVal);` |
| `UntarMaxCount` | property, read/write | `# intVal is an integer intVal = tar.get_UntarMaxCount(); tar.put_UntarMaxCount(intVal);` |
| `UserId` | property, read/write | `# intVal is an integer intVal = tar.get_UserId(); tar.put_UserId(intVal);` |
| `UserName` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_UserName(ckStr); strVal = tar.userName(); tar.put_UserName(strVal);` |
| `WriteFormat` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_WriteFormat(ckStr); strVal = tar.writeFormat(); tar.put_WriteFormat(strVal);` |
| `XmlListing` | property, read/write | `# strVal is a string # ckStr is a CkString tar.get_XmlListing(ckStr); strVal = tar.xmlListing(); tar.put_XmlListing(strVal);` |
| `AddDirRoot` | method | `# dirPath is a string status = tar.AddDirRoot(dirPath);` |
| `AddDirRoot2` | method | `# rootPrefix is a string # rootPath is a string status = tar.AddDirRoot2(rootPrefix, rootPath);` |
| `AddFile` | method | `# path is a string status = tar.AddFile(path);` |
| `AddFile2` | method | `# filePath is a string # pathWithinTar is a string status = tar.AddFile2(filePath, pathWithinTar);` |
| `ClearDirRootsAndFiles` | method | `status = tar.ClearDirRootsAndFiles();` |
| `CreateDeb` | method | `# controlPath is a string # dataPath is a string # debPath is a string status = tar.CreateDeb(controlPath, dataPath, debPath);` |
| `GetDirRoot` | method | `# index is an integer # outStr is a CkString (output) status = tar.GetDirRoot(index, outStr); retStr = tar.getDirRoot(index);` |
| `ListXml` | method | `# tarPath is a string # outStr is a CkString (output) status = tar.ListXml(tarPath, outStr); retStr = tar.listXml(tarPath);` |
| `LoadTaskCaller` | method | `# task is a CkTask status = tar.LoadTaskCaller(task);` |
| `Untar` | method | `# tarPath is a string retInt = tar.Untar(tarPath);` |
| `UntarBz2` | method | `# tarPath is a string status = tar.UntarBz2(tarPath);` |
| `UntarFirstMatchingToBd` | method | `# tarPath is a string # matchPattern is a string # bd is a CkBinData status = tar.UntarFirstMatchingToBd(tarPath, matchPattern, bd);` |
| `UntarGz` | method | `# tarPath is a string status = tar.UntarGz(tarPath);` |
| `UntarZ` | method | `# tarPath is a string status = tar.UntarZ(tarPath);` |
| `VerifyTar` | method | `# tarPath is a string retBool = tar.VerifyTar(tarPath);` |
| `WriteTar` | method | `# tarPath is a string status = tar.WriteTar(tarPath);` |
| `WriteTarBz2` | method | `# bz2Path is a string status = tar.WriteTarBz2(bz2Path);` |
| `WriteTarGz` | method | `# gzPath is a string status = tar.WriteTarGz(gzPath);` |

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

## Properties

### Tar.CaptureXmlListing

`Chilkat 11.7.0 · ckruby · Tar · CaptureXmlListing · property · read/write · since 9.5.0.46`

```ruby
# boolVal is a boolean

boolVal = tar.get_CaptureXmlListing();

tar.put_CaptureXmlListing(boolVal);
```

Controls whether extraction methods also capture an XML inventory of the archive. When set to `true`, methods such as `Untar`, `UntarGz`, `UntarBz2`, and `UntarZ` store the listing in `XmlListing`. The XML has the same structure as the string returned by `ListXml`. The default is `false`.

**Inspect without extracting:** Set `CaptureXmlListing` and `SuppressOutput` to `true` before an untar operation to scan the archive and obtain its XML listing without writing archive entries to disk.

### Tar.Charset

`Chilkat 11.7.0 · ckruby · Tar · Charset · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_Charset(ckStr);

strVal = tar.charset();

tar.put_Charset(strVal);
```

Specifies the character encoding used to decode filenames stored in a TAR archive during extraction. The default is `utf-8`, which is normally appropriate for modern archives.

This property affects archive entry names only. It does not convert or otherwise alter the contents of extracted files. TAR archives written by the `WriteTar*` methods store filenames as UTF-8.

**Filename interoperability:** The original TAR header format does not always identify the character encoding of a filename. Change this property only when an older archive is known to use a different encoding.

### Tar.DirMode

`Chilkat 11.7.0 · ckruby · Tar · DirMode · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_DirMode();

tar.put_DirMode(intVal);
```

Specifies the UNIX permission bits written to the TAR header for directory entries created by the `WriteTar*` methods. The default is octal `0755`, which represents `rwxr-xr-x`.

**Archive metadata:** This value records permissions in the archive. Whether the exact permissions are restored during extraction depends on the destination operating system, filesystem, process privileges, and local security policy.

### Tar.DirPrefix

`Chilkat 11.7.0 · ckruby · Tar · DirPrefix · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_DirPrefix(ckStr);

strVal = tar.dirPrefix();

tar.put_DirPrefix(strVal);
```

Specifies a path prefix to prepend to entries when a TAR archive is created. For example, setting this property to `subdir1` causes an entry such as `report.txt` to be stored as `subdir1/report.txt`.

The prefix changes only the path stored in the archive; it does not rename or move the source file on disk.

**AddFile2 exception:** `AddFile2` explicitly supplies the complete path within the archive, so `DirPrefix` is not applied to files added by that method.

### Tar.FileMode

`Chilkat 11.7.0 · ckruby · Tar · FileMode · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_FileMode();

tar.put_FileMode(intVal);
```

Specifies the UNIX permission bits written to the TAR header for ordinary file entries created by the `WriteTar*` methods. The default is octal `0644`, which represents `rw-r--r--`.

**Shell scripts:** Files recognized as shell scripts use `ScriptFileMode` instead, allowing executable permissions to be recorded separately.

### Tar.GroupId

`Chilkat 11.7.0 · ckruby · Tar · GroupId · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_GroupId();

tar.put_GroupId(intVal);
```

Specifies the numeric group identifier (GID) written to TAR headers when an archive is created. The default value is `1000`.

**Ownership metadata:** A stored GID is archive metadata. Restoring ownership may require elevated privileges and may be ignored or mapped differently on non-UNIX systems.

### Tar.GroupName

`Chilkat 11.7.0 · ckruby · Tar · GroupName · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_GroupName(ckStr);

strVal = tar.groupName();

tar.put_GroupName(strVal);
```

Specifies the group name written to TAR headers when an archive is created. By default, Chilkat uses the username of the account running the application.

**Name versus numeric ID:** TAR headers can contain both a group name and the numeric `GroupId`. Extraction tools and operating systems may give different precedence to these fields.

### Tar.MatchCaseSensitive

`Chilkat 11.7.0 · ckruby · Tar · MatchCaseSensitive · property · read/write · since 9.5.0.46`

```ruby
# boolVal is a boolean

boolVal = tar.get_MatchCaseSensitive();

tar.put_MatchCaseSensitive(boolVal);
```

Controls whether the patterns in `MustMatch` and `MustNotMatch` are matched case-sensitively. The default is `false`.

**Cross-platform behavior:** Case sensitivity in the archive filter is independent of whether the local filesystem itself treats filenames as case-sensitive.

### Tar.MustMatch

`Chilkat 11.7.0 · ckruby · Tar · MustMatch · property · read/write · since 9.5.0.46`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_MustMatch(ckStr);

strVal = tar.mustMatch();

tar.put_MustMatch(strVal);
```

Specifies an inclusion pattern applied when creating or extracting TAR archives, including compressed TAR formats. A candidate path is included or extracted only when it matches this pattern. The default is an empty string, which permits all paths.

The pattern may contain zero or more asterisks (`*`), where each asterisk matches zero or more characters. For example, `*.txt` selects paths ending in `.txt`. Case handling is controlled by `MatchCaseSensitive`.

**Combined filters:** If both `MustMatch` and `MustNotMatch` are set, a path must satisfy the inclusion pattern and must not satisfy the exclusion pattern.

### Tar.MustNotMatch

`Chilkat 11.7.0 · ckruby · Tar · MustNotMatch · property · read/write · since 9.5.0.46`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_MustNotMatch(ckStr);

strVal = tar.mustNotMatch();

tar.put_MustNotMatch(strVal);
```

Specifies an exclusion pattern applied when creating or extracting TAR archives, including compressed TAR formats. A candidate path that matches this pattern is skipped. The default is an empty string, which excludes nothing.

The pattern may contain zero or more asterisks (`*`), where each asterisk matches zero or more characters. For example, `*.obj` skips paths ending in `.obj`. Case handling is controlled by `MatchCaseSensitive`.

**Exclusion takes effect after inclusion:** When both filters are set, matching `MustMatch` does not override a match in `MustNotMatch`.

### Tar.NoAbsolutePaths

`Chilkat 11.7.0 · ckruby · Tar · NoAbsolutePaths · property · read/write`

```ruby
# boolVal is a boolean

boolVal = tar.get_NoAbsolutePaths();

tar.put_NoAbsolutePaths(boolVal);
```

Controls whether absolute archive paths are converted to relative paths during extraction. When `true`, a leading `/` or `\` is removed before the entry is written. The default is `true`.

**Recommended security setting:** Keep this property enabled when extracting archives you did not create. Also extract untrusted archives into a dedicated directory and inspect their entry names before relying on the extracted content.

### Tar.NumDirRoots

`Chilkat 11.7.0 · ckruby · Tar · NumDirRoots · property · read-only`

```ruby
# intVal is an integer

intVal = tar.get_NumDirRoots();
```

Returns the number of directory roots currently registered for archive creation by calls to `AddDirRoot` and `AddDirRoot2`. Individual files added with `AddFile` or `AddFile2` are not included in this count.

Use zero-based indexes from `0` through `NumDirRoots - 1` with `GetDirRoot`.

### Tar.ScriptFileMode

`Chilkat 11.7.0 · ckruby · Tar · ScriptFileMode · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_ScriptFileMode();

tar.put_ScriptFileMode(intVal);
```

Specifies the UNIX permission bits written to TAR headers for shell-script files recognized by extensions such as `.sh`, `.csh`, `.bash`, and `.bsh`. The default is octal `0755`, which records executable permissions.

**Other files:** Non-script files use `FileMode`; directories use `DirMode`.

### Tar.SuppressOutput

`Chilkat 11.7.0 · ckruby · Tar · SuppressOutput · property · read/write · since 9.5.0.46`

```ruby
# boolVal is a boolean

boolVal = tar.get_SuppressOutput();

tar.put_SuppressOutput(boolVal);
```

Controls whether untar operations write extracted files and directories to the filesystem. When `true`, methods such as `Untar`, `UntarGz`, `UntarBz2`, and `UntarZ` scan the archive without producing extracted output. The default is `false`.

**Archive inventory workflow:** Combine this property with `CaptureXmlListing` to obtain an XML listing without extracting the archive.

### Tar.UntarCaseSensitive

`Chilkat 11.7.0 · ckruby · Tar · UntarCaseSensitive · property · read/write`

```ruby
# boolVal is a boolean

boolVal = tar.get_UntarCaseSensitive();

tar.put_UntarCaseSensitive(boolVal);
```

**Deprecated.** Use `MatchCaseSensitive` instead.

Until this property is removed, reading or setting it has the same effect as reading or setting `MatchCaseSensitive`.

### Tar.UntarDebugLog

`Chilkat 11.7.0 · ckruby · Tar · UntarDebugLog · property · read/write`

```ruby
# boolVal is a boolean

boolVal = tar.get_UntarDebugLog();

tar.put_UntarDebugLog(boolVal);
```

Controls whether untar methods add per-entry extraction details to `LastErrorText`, `LastErrorXml`, and `LastErrorHtml`. The default is `false`.

**Diagnostic output is not necessarily an error:** When this property is enabled, the LastError properties can contain useful extraction trace information even after a successful operation.

### Tar.UntarDiscardPaths

`Chilkat 11.7.0 · ckruby · Tar · UntarDiscardPaths · property · read/write`

```ruby
# boolVal is a boolean

boolVal = tar.get_UntarDiscardPaths();

tar.put_UntarDiscardPaths(boolVal);
```

Controls whether directory components from archive entry names are discarded during extraction. When `true`, each file is written directly into `UntarFromDir` rather than recreating the archived directory tree. The default is `false`.

**Filename collisions:** Different archive entries can have the same final filename after their directory paths are removed. Use this option only when flattening the archive is intentional and potential collisions are acceptable.

### Tar.UntarFromDir

`Chilkat 11.7.0 · ckruby · Tar · UntarFromDir · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_UntarFromDir(ckStr);

strVal = tar.untarFromDir();

tar.put_UntarFromDir(strVal);
```

Specifies the destination directory for extraction. The default is `.`, meaning the current working directory of the calling process.

When `UntarDiscardPaths` is `false`, archived subdirectories are recreated beneath this directory. When it is `true`, extracted files are placed directly in this directory.

**Safer extraction:** For untrusted archives, choose a new or otherwise isolated destination directory rather than extracting directly into an application or system directory.

### Tar.UntarMaxCount

`Chilkat 11.7.0 · ckruby · Tar · UntarMaxCount · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_UntarMaxCount();

tar.put_UntarMaxCount(intVal);
```

Limits the number of matching entries extracted by an untar operation. The default is `0`, which means no maximum.

For example, set `MustMatch` to select a particular path and set `UntarMaxCount` to `1` to stop after the first matching entry is extracted.

**Archive order matters:** When a limit is used, extraction stops after the configured number of matches in archive order.

### Tar.UserId

`Chilkat 11.7.0 · ckruby · Tar · UserId · property · read/write`

```ruby
# intVal is an integer

intVal = tar.get_UserId();

tar.put_UserId(intVal);
```

Specifies the numeric user identifier (UID) written to TAR headers when an archive is created. The default value is `1000`.

**Ownership metadata:** A stored UID does not by itself change the owner of a local source file. Restoring ownership during extraction may require elevated privileges and may not apply on non-UNIX systems.

### Tar.UserName

`Chilkat 11.7.0 · ckruby · Tar · UserName · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_UserName(ckStr);

strVal = tar.userName();

tar.put_UserName(strVal);
```

Specifies the user name written to TAR headers when an archive is created. By default, Chilkat uses the username of the account running the application.

**Name versus numeric ID:** TAR headers can contain both a user name and the numeric `UserId`. Their interpretation depends on the extracting tool and destination system.

### Tar.WriteFormat

`Chilkat 11.7.0 · ckruby · Tar · WriteFormat · property · read/write`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_WriteFormat(ckStr);

strVal = tar.writeFormat();

tar.put_WriteFormat(strVal);
```

Specifies the TAR header format used by the `WriteTar*` methods. The default is `gnu`. Supported values are:

| Value | Use |
| :--- | :--- |
| `gnu` | GNU TAR format and extensions. This is the Chilkat default and supports archive metadata beyond classic ustar limits. |
| `pax` | POSIX pax extended format. It is designed to represent long names and additional metadata through extensible records. |
| `ustar` | POSIX ustar format. It is broadly interoperable but has stricter limits on path lengths and metadata fields. |

**Choosing a format:** Use `ustar` when compatibility with simple TAR readers is the priority and the archive fits its limits. Use `pax` for portable extended metadata, or retain `gnu` when GNU TAR compatibility is expected.

### Tar.XmlListing

`Chilkat 11.7.0 · ckruby · Tar · XmlListing · property · read/write · since 9.5.0.46`

```ruby
# strVal is a string

# ckStr is a CkString

tar.get_XmlListing(ckStr);

strVal = tar.xmlListing();

tar.put_XmlListing(strVal);
```

Contains the XML listing captured by the most recent untar operation for which `CaptureXmlListing` was `true`. The XML structure is the same as the output from `ListXml`.

**Read after the operation:** Use the untar method's return value to confirm that the archive was processed successfully before consuming this property.

## Methods

### Tar.AddDirRoot

`Chilkat 11.7.0 · ckruby · Tar · AddDirRoot · method`

```ruby
# dirPath is a string

status = tar.AddDirRoot(dirPath);
```

Adds the directory tree at `dirPath` to the set of sources used by the next `WriteTar*` operation. Call this method multiple times to include multiple directory trees in one archive.

Use `AddDirRoot2` when the tree should appear beneath an explicit prefix inside the archive.

**Queued archive sources:** Directory roots and files are retained by the object until `ClearDirRootsAndFiles` is called.

Returns true for success, false for failure.

### Tar.AddDirRoot2

`Chilkat 11.7.0 · ckruby · Tar · AddDirRoot2 · method · since 9.5.0.56`

```ruby
# rootPrefix is a string

# rootPath is a string

status = tar.AddDirRoot2(rootPrefix, rootPath);
```

Adds the directory tree at `rootPath` to the archive-creation source list and stores its entries beneath the archive prefix supplied in `rootPrefix`. Call this method multiple times, or combine it with `AddDirRoot`, before calling a `WriteTar*` method.

`rootPrefix` should be a relative archive path such as `abc/123` and should not end with `/`. If `DirPrefix` is also set, `DirPrefix` is applied first.

**Path composition example:** With `DirPrefix = "package"` and `rootPrefix = "assets"`, files from this root are stored beneath `package/assets/`.

Returns true for success, false for failure.

### Tar.AddFile

`Chilkat 11.7.0 · ckruby · Tar · AddFile · method · since 9.5.0.46`

```ruby
# path is a string

status = tar.AddFile(path);
```

Adds the local file at `path` to the set of sources used by the next `WriteTar*` operation. Call `AddFile`, `AddFile2`, and the directory-root methods as needed before writing a single archive.

Use `AddFile2` when the path stored inside the TAR must be specified independently of the source file path.

**Queued archive sources:** Added files and directory roots remain associated with the object until `ClearDirRootsAndFiles` is called.

Returns true for success, false for failure.

### Tar.AddFile2

`Chilkat 11.7.0 · ckruby · Tar · AddFile2 · method · since 9.5.0.69`

```ruby
# filePath is a string

# pathWithinTar is a string

status = tar.AddFile2(filePath, pathWithinTar);
```

Adds the local file at `filePath` to the archive-creation source list and stores it using the exact archive path supplied in `pathWithinTar`. This allows the source path and the path visible inside the TAR to differ.

Call this method as many times as needed, optionally together with the other file and directory-root methods, before calling a single `WriteTar*` method.

**DirPrefix is not applied:** Because `pathWithinTar` already specifies the path within the TAR, `DirPrefix` does not modify entries added by this method. Use forward slashes and a relative path for portable archive names.

Returns true for success, false for failure.

### Tar.ClearDirRootsAndFiles

`Chilkat 11.7.0 · ckruby · Tar · ClearDirRootsAndFiles · method · since 9.5.0.84`

```ruby
status = tar.ClearDirRootsAndFiles();
```

Removes all files and directory roots previously registered by `AddDirRoot`, `AddDirRoot2`, `AddFile`, and `AddFile2`.

Call this method before building a different archive with the same `Tar` object when the earlier source list should not be reused.

Returns true for success, false for failure.

### Tar.CreateDeb

`Chilkat 11.7.0 · ckruby · Tar · CreateDeb · method · since 9.5.0.66`

```ruby
# controlPath is a string

# dataPath is a string

# debPath is a string

status = tar.CreateDeb(controlPath, dataPath, debPath);
```

Creates a Debian binary package at `debPath` from the prepared control archive at `controlPath` and data archive at `dataPath`. The inputs are typically named `control.tar.gz` and `data.tar.gz`, or use another compression form accepted by the target Debian tooling.

**Debian package structure:** A modern `.deb` file is an `ar` archive containing a `debian-binary` format marker, a `control.tar.*` member for package metadata and maintainer scripts, and a `data.tar.*` member for the installed filesystem payload.

**Prepared inputs required:** This method packages the supplied control and data tarballs. The caller is responsible for making their directory layout, control metadata, permissions, and package contents valid for Debian package-management tools.

Returns true for success, false for failure.

### Tar.GetDirRoot

`Chilkat 11.7.0 · ckruby · Tar · GetDirRoot · method`

```ruby
# index is an integer

# outStr is a CkString (output)

status = tar.GetDirRoot(index, outStr);

retStr = tar.getDirRoot(index);
```

Returns a directory root previously added with `AddDirRoot` or `AddDirRoot2`. `index` is a zero-based index.

Valid indexes range from `0` through `NumDirRoots - 1`. For example, after two roots are added, `GetDirRoot(0)` returns the first and `GetDirRoot(1)` returns the second.

Returns true for success, false for failure.

### Tar.ListXml

`Chilkat 11.7.0 · ckruby · Tar · ListXml · method`

```ruby
# tarPath is a string

# outStr is a CkString (output)

status = tar.ListXml(tarPath, outStr);

retStr = tar.listXml(tarPath);
```

Scans the uncompressed TAR archive at `tarPath` and returns an XML description of its files, directories, and archive metadata. The archive is not extracted.

**Compressed tarballs:** For a compressed TAR archive, an untar method can capture the same listing format by setting `CaptureXmlListing`. Set `SuppressOutput` as well when no files should be written.

Returns true for success, false for failure.

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

### Tar.LoadTaskCaller

`Chilkat 11.7.0 · ckruby · Tar · LoadTaskCaller · method · since 9.5.0.80`

```ruby
# task is a CkTask

status = tar.LoadTaskCaller(task);
```

Loads the caller object associated with `task`, an asynchronous Chilkat `Task`, into this `Tar` object.

**Specialized async support:** This method supports Chilkat task-caller plumbing and is not normally needed in ordinary archive code. Use it only when a Chilkat example or support instruction specifically requires it.

Returns true for success, false for failure.

### Tar.Untar

`Chilkat 11.7.0 · ckruby · Tar · Untar · method`

```ruby
# tarPath is a string

retInt = tar.Untar(tarPath);
```

Extracts the uncompressed TAR archive at `tarPath` into the directory specified by `UntarFromDir`. Archived directory trees are recreated unless `UntarDiscardPaths` is `true`.

Returns the number of files and directories extracted, or `-1` if the operation fails. Extraction is also affected by the matching, path-safety, count-limit, listing, and output-suppression properties of this object.

**TAR is a container format:** An ordinary `.tar` archive is not compressed. Use `UntarGz`, `UntarBz2`, or `UntarZ` for the corresponding compressed tarball formats.

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

### Tar.UntarBz2

`Chilkat 11.7.0 · ckruby · Tar · UntarBz2 · method`

```ruby
# tarPath is a string

status = tar.UntarBz2(tarPath);
```

Decompresses and extracts the `.tar.bz2` archive at `tarPath` into `UntarFromDir`. This format is also commonly named `.tbz`, `.tbz2`, or `.tb2`.

Returns `true` on success and `false` on failure. The same extraction filters, path controls, listing options, and output settings used by `Untar` also apply.

Returns true for success, false for failure.

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

### Tar.UntarFirstMatchingToBd

`Chilkat 11.7.0 · ckruby · Tar · UntarFirstMatchingToBd · method · since 9.5.0.82`

```ruby
# tarPath is a string

# matchPattern is a string

# bd is a CkBinData

status = tar.UntarFirstMatchingToBd(tarPath, matchPattern, bd);
```

Scans the uncompressed TAR archive at `tarPath` and copies the contents of the first file whose archive path matches `matchPattern` into the `BinData` object supplied in `bd`. Matching is evaluated in archive order.

No archive entry is written to the local filesystem. Returns `true` when a matching file is successfully extracted to `bd` and `false` otherwise.

Returns true for success, false for failure.

### Tar.UntarGz

`Chilkat 11.7.0 · ckruby · Tar · UntarGz · method`

```ruby
# tarPath is a string

status = tar.UntarGz(tarPath);
```

Decompresses and extracts the `.tar.gz` archive at `tarPath` into `UntarFromDir`. The `.tgz` extension is a common short form for the same gzip-compressed TAR structure.

Returns `true` on success and `false` on failure. The same extraction filters, path controls, listing options, and output settings used by `Untar` also apply.

Returns true for success, false for failure.

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

### Tar.UntarZ

`Chilkat 11.7.0 · ckruby · Tar · UntarZ · method`

```ruby
# tarPath is a string

status = tar.UntarZ(tarPath);
```

Decompresses and extracts the `.tar.Z` archive at `tarPath` into `UntarFromDir`. The `.Z` suffix denotes the historical UNIX `compress` format; `.taz` is a common alternate extension.

Returns `true` on success and `false` on failure. The same extraction filters, path controls, listing options, and output settings used by `Untar` also apply.

Returns true for success, false for failure.

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

### Tar.VerifyTar

`Chilkat 11.7.0 · ckruby · Tar · VerifyTar · method`

```ruby
# tarPath is a string

retBool = tar.VerifyTar(tarPath);
```

Opens the uncompressed TAR archive at `tarPath` and scans its headers through the end of the archive. Returns `true` when the archive structure is accepted and no TAR-format errors are found; otherwise returns `false`.

**What verification does not establish:** Structural verification does not prove that archived files are safe, trustworthy, or appropriate to extract. It is not malware scanning and does not authenticate the archive publisher.

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

### Tar.WriteTar

`Chilkat 11.7.0 · ckruby · Tar · WriteTar · method`

```ruby
# tarPath is a string

status = tar.WriteTar(tarPath);
```

Creates an uncompressed TAR archive at `tarPath` from the files and directory trees previously added with `AddFile`, `AddFile2`, `AddDirRoot`, and `AddDirRoot2`. Archive paths, permissions, ownership metadata, filters, and header format are controlled by the corresponding properties.

Returns `true` on success and `false` on failure.

Returns true for success, false for failure.

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

### Tar.WriteTarBz2

`Chilkat 11.7.0 · ckruby · Tar · WriteTarBz2 · method`

```ruby
# bz2Path is a string

status = tar.WriteTarBz2(bz2Path);
```

Creates a bzip2-compressed TAR archive at `bz2Path` from the files and directory trees previously added to this object. Common filename extensions include `.tar.bz2`, `.tbz`, `.tbz2`, and `.tb2`.

Returns `true` on success and `false` on failure.

**Two-layer format:** The result is a TAR byte stream compressed with bzip2. TAR supplies the multi-file archive structure; bzip2 supplies compression.

Returns true for success, false for failure.

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

### Tar.WriteTarGz

`Chilkat 11.7.0 · ckruby · Tar · WriteTarGz · method`

```ruby
# gzPath is a string

status = tar.WriteTarGz(gzPath);
```

Creates a gzip-compressed TAR archive at `gzPath` from the files and directory trees previously added to this object. The usual extensions are `.tar.gz` and `.tgz`.

Returns `true` on success and `false` on failure.

**Two-layer format:** The result is a TAR byte stream compressed with gzip. TAR supplies the multi-file archive structure; gzip supplies compression.

Returns true for success, false for failure.

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

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

```ruby
# returns a CkTask

# tarPath is a string

ret_task = tar.ListXmlAsync(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.UntarAsync(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.UntarBz2Async(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.UntarGzAsync(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.UntarZAsync(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.VerifyTarAsync(tarPath);
# returns a CkTask

# tarPath is a string

ret_task = tar.WriteTarAsync(tarPath);
# returns a CkTask

# bz2Path is a string

ret_task = tar.WriteTarBz2Async(bz2Path);
# returns a CkTask

# gzPath is a string

ret_task = tar.WriteTarGzAsync(gzPath);
```

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `UntarFirstMatchingToMemory` | method | before 11.6.1 | — |
| `UntarFromMemory` | method | before 11.6.1 | — |

## Related classes

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

