Class Tar

All Implemented Interfaces:
AutoCloseable

public class Tar extends ChilkatObject
<section class="tar-summary">

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.

</section>

Event-capable: long-running methods report progress through a ProgressListener installed with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier), onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).

Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when done; an unclosed instance is freed when it becomes unreachable.

See Also:
Online reference
  • Constructor Details

    • Tar

      public Tar()
      Creates a new Tar object.
  • Method Details

    • getCaptureXmlListing

      public boolean getCaptureXmlListing()
      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 getXmlListing(). The XML has the same structure as the string returned by listXml(String). The default is false.

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

      Returns:
      the value of the CaptureXmlListing property
    • setCaptureXmlListing

      public void setCaptureXmlListing​(boolean value)
      Sets the CaptureXmlListing property; see getCaptureXmlListing().
      Parameters:
      value - the new value
    • getCharset

      public String getCharset()
      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.

      Returns:
      the value of the Charset property
    • setCharset

      public void setCharset​(String value)
      Sets the Charset property; see getCharset().
      Parameters:
      value - the new value (not null)
    • getDirMode

      public int getDirMode()
      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.

      Returns:
      the value of the DirMode property
    • setDirMode

      public void setDirMode​(int value)
      Sets the DirMode property; see getDirMode().
      Parameters:
      value - the new value
    • getDirPrefix

      public String getDirPrefix()
      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(String, String) explicitly supplies the complete path within the archive, so DirPrefix is not applied to files added by that method.

      Returns:
      the value of the DirPrefix property
    • setDirPrefix

      public void setDirPrefix​(String value)
      Sets the DirPrefix property; see getDirPrefix().
      Parameters:
      value - the new value (not null)
    • getFileMode

      public int getFileMode()
      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 getScriptFileMode() instead, allowing executable permissions to be recorded separately.

      Returns:
      the value of the FileMode property
    • setFileMode

      public void setFileMode​(int value)
      Sets the FileMode property; see getFileMode().
      Parameters:
      value - the new value
    • getGroupId

      public int getGroupId()
      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.

      Returns:
      the value of the GroupId property
    • setGroupId

      public void setGroupId​(int value)
      Sets the GroupId property; see getGroupId().
      Parameters:
      value - the new value
    • getGroupName

      public String getGroupName()
      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 getGroupId(). Extraction tools and operating systems may give different precedence to these fields.

      Returns:
      the value of the GroupName property
    • setGroupName

      public void setGroupName​(String value)
      Sets the GroupName property; see getGroupName().
      Parameters:
      value - the new value (not null)
    • getHeartbeatMs

      public int getHeartbeatMs()
      Specifies the approximate interval, in milliseconds, between AbortCheck event callbacks during supported long-running operations. The default is 0, which disables periodic AbortCheck callbacks.

      Cancellation is cooperative: A callback can request that an operation stop, but the request is observed only when the running method reaches a cancellation check. Short operations may finish before a callback occurs.

      Returns:
      the value of the HeartbeatMs property
    • setHeartbeatMs

      public void setHeartbeatMs​(int value)
      Sets the HeartbeatMs property; see getHeartbeatMs().
      Parameters:
      value - the new value
    • getMatchCaseSensitive

      public boolean getMatchCaseSensitive()
      Controls whether the patterns in getMustMatch() and getMustNotMatch() 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.

      Returns:
      the value of the MatchCaseSensitive property
    • setMatchCaseSensitive

      public void setMatchCaseSensitive​(boolean value)
      Sets the MatchCaseSensitive property; see getMatchCaseSensitive().
      Parameters:
      value - the new value
    • getMustMatch

      public String getMustMatch()
      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 getMatchCaseSensitive().

      Combined filters: If both MustMatch and getMustNotMatch() are set, a path must satisfy the inclusion pattern and must not satisfy the exclusion pattern.

      Returns:
      the value of the MustMatch property
    • setMustMatch

      public void setMustMatch​(String value)
      Sets the MustMatch property; see getMustMatch().
      Parameters:
      value - the new value (not null)
    • getMustNotMatch

      public String getMustNotMatch()
      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 getMatchCaseSensitive().

      Exclusion takes effect after inclusion: When both filters are set, matching getMustMatch() does not override a match in MustNotMatch.

      Returns:
      the value of the MustNotMatch property
    • setMustNotMatch

      public void setMustNotMatch​(String value)
      Sets the MustNotMatch property; see getMustNotMatch().
      Parameters:
      value - the new value (not null)
    • getNoAbsolutePaths

      public boolean getNoAbsolutePaths()
      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.

      Returns:
      the value of the NoAbsolutePaths property
    • setNoAbsolutePaths

      public void setNoAbsolutePaths​(boolean value)
      Sets the NoAbsolutePaths property; see getNoAbsolutePaths().
      Parameters:
      value - the new value
    • getNumDirRoots

      public int getNumDirRoots()
      Returns the number of directory roots currently registered for archive creation by calls to addDirRoot(String) and addDirRoot2(String, String). Individual files added with AddFile or AddFile2 are not included in this count.

      Use zero-based indexes from 0 through NumDirRoots - 1 with getDirRoot(int).

      Returns:
      the value of the NumDirRoots property (read-only)
    • getPercentDoneScale

      public int getPercentDoneScale()
      Specifies the value reported by PercentDone when an eligible operation is 100% complete. The default is 100. Increasing the scale allows finer-grained integer progress values; for example, a scale of 1000 allows 453 to represent 45.3%.

      The value is clamped to the range 10 through 100000. This property is available only in environments that support event callbacks, and only methods for which measurable progress is available emit percentage updates.

      Scale, not frequency: A larger scale increases the numeric resolution of progress values but does not guarantee a callback for every possible value.

      Returns:
      the value of the PercentDoneScale property
    • setPercentDoneScale

      public void setPercentDoneScale​(int value)
      Sets the PercentDoneScale property; see getPercentDoneScale().
      Parameters:
      value - the new value
    • getScriptFileMode

      public int getScriptFileMode()
      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 getFileMode(); directories use getDirMode().

      Returns:
      the value of the ScriptFileMode property
    • setScriptFileMode

      public void setScriptFileMode​(int value)
      Sets the ScriptFileMode property; see getScriptFileMode().
      Parameters:
      value - the new value
    • getSuppressOutput

      public boolean getSuppressOutput()
      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 getCaptureXmlListing() to obtain an XML listing without extracting the archive.

      Returns:
      the value of the SuppressOutput property
    • setSuppressOutput

      public void setSuppressOutput​(boolean value)
      Sets the SuppressOutput property; see getSuppressOutput().
      Parameters:
      value - the new value
    • getUntarCaseSensitive

      public boolean getUntarCaseSensitive()
      Deprecated. Use getMatchCaseSensitive() instead.

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

      Returns:
      the value of the UntarCaseSensitive property
    • setUntarCaseSensitive

      public void setUntarCaseSensitive​(boolean value)
      Sets the UntarCaseSensitive property; see getUntarCaseSensitive().
      Parameters:
      value - the new value
    • getUntarDebugLog

      public boolean getUntarDebugLog()
      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.

      Returns:
      the value of the UntarDebugLog property
    • setUntarDebugLog

      public void setUntarDebugLog​(boolean value)
      Sets the UntarDebugLog property; see getUntarDebugLog().
      Parameters:
      value - the new value
    • getUntarDiscardPaths

      public boolean getUntarDiscardPaths()
      Controls whether directory components from archive entry names are discarded during extraction. When true, each file is written directly into getUntarFromDir() 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.

      Returns:
      the value of the UntarDiscardPaths property
    • setUntarDiscardPaths

      public void setUntarDiscardPaths​(boolean value)
      Sets the UntarDiscardPaths property; see getUntarDiscardPaths().
      Parameters:
      value - the new value
    • getUntarFromDir

      public String getUntarFromDir()
      Specifies the destination directory for extraction. The default is ., meaning the current working directory of the calling process.

      When getUntarDiscardPaths() 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.

      Returns:
      the value of the UntarFromDir property
    • setUntarFromDir

      public void setUntarFromDir​(String value)
      Sets the UntarFromDir property; see getUntarFromDir().
      Parameters:
      value - the new value (not null)
    • getUntarMaxCount

      public int getUntarMaxCount()
      Limits the number of matching entries extracted by an untar operation. The default is 0, which means no maximum.

      For example, set getMustMatch() 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.

      Returns:
      the value of the UntarMaxCount property
    • setUntarMaxCount

      public void setUntarMaxCount​(int value)
      Sets the UntarMaxCount property; see getUntarMaxCount().
      Parameters:
      value - the new value
    • getUserId

      public int getUserId()
      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.

      Returns:
      the value of the UserId property
    • setUserId

      public void setUserId​(int value)
      Sets the UserId property; see getUserId().
      Parameters:
      value - the new value
    • getUserName

      public String getUserName()
      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 getUserId(). Their interpretation depends on the extracting tool and destination system.

      Returns:
      the value of the UserName property
    • setUserName

      public void setUserName​(String value)
      Sets the UserName property; see getUserName().
      Parameters:
      value - the new value (not null)
    • getWriteFormat

      public String getWriteFormat()
      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.

      Returns:
      the value of the WriteFormat property
    • setWriteFormat

      public void setWriteFormat​(String value)
      Sets the WriteFormat property; see getWriteFormat().
      Parameters:
      value - the new value (not null)
    • getXmlListing

      public String getXmlListing()
      Contains the XML listing captured by the most recent untar operation for which getCaptureXmlListing() was true. The XML structure is the same as the output from listXml(String).

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

      Returns:
      the value of the XmlListing property
    • setXmlListing

      public void setXmlListing​(String value)
      Sets the XmlListing property; see getXmlListing().
      Parameters:
      value - the new value (not null)
    • addDirRoot

      public void addDirRoot​(String 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(String, String) 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.

      Parameters:
      dirPath - the dirPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addDirRoot2

      public void addDirRoot2​(String rootPrefix, String 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(String), before calling a WriteTar* method.

      rootPrefix should be a relative archive path such as abc/123 and should not end with /. If getDirPrefix() 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/.

      Parameters:
      rootPrefix - the rootPrefix argument (not null)
      rootPath - the rootPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addFile

      public void addFile​(String 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(String, String) 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.

      Parameters:
      path - the path argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • addFile2

      public void addFile2​(String filePath, String 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, getDirPrefix() does not modify entries added by this method. Use forward slashes and a relative path for portable archive names.

      Parameters:
      filePath - the filePath argument (not null)
      pathWithinTar - the pathWithinTar argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • clearDirRootsAndFiles

      public void clearDirRootsAndFiles()
      Removes all files and directory roots previously registered by addDirRoot(String), addDirRoot2(String, String), addFile(String), and addFile2(String, String).

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

      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • createDeb

      public void createDeb​(String controlPath, String dataPath, String 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.

      Parameters:
      controlPath - the controlPath argument (not null)
      dataPath - the dataPath argument (not null)
      debPath - the debPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • getDirRoot

      public String getDirRoot​(int index)
      Returns a directory root previously added with addDirRoot(String) or addDirRoot2(String, String). index is a zero-based index.

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

      Parameters:
      index - the index argument
      Returns:
      the result (never null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • listXml

      public String listXml​(String 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 getCaptureXmlListing(). Set getSuppressOutput() as well when no files should be written.

      Parameters:
      tarPath - the tarPath argument (not null)
      Returns:
      the result (never null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • untar

      public int untar​(String tarPath)
      Extracts the uncompressed TAR archive at tarPath into the directory specified by getUntarFromDir(). Archived directory trees are recreated unless getUntarDiscardPaths() 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.

      Parameters:
      tarPath - the tarPath argument (not null)
      Returns:
      the result (see ChilkatObject.getLastMethodSuccess() where the description mentions failure)
    • untarBz2

      public void untarBz2​(String tarPath)
      Decompresses and extracts the .tar.bz2 archive at tarPath into getUntarFromDir(). 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(String) also apply.

      Parameters:
      tarPath - the tarPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • untarFirstMatchingToBd

      public void untarFirstMatchingToBd​(String tarPath, String matchPattern, BinData 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.

      Parameters:
      tarPath - the tarPath argument (not null)
      matchPattern - the matchPattern argument (not null)
      bd - the bd argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • untarGz

      public void untarGz​(String tarPath)
      Decompresses and extracts the .tar.gz archive at tarPath into getUntarFromDir(). 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(String) also apply.

      Parameters:
      tarPath - the tarPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • untarZ

      public void untarZ​(String tarPath)
      Decompresses and extracts the .tar.Z archive at tarPath into getUntarFromDir(). 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(String) also apply.

      Parameters:
      tarPath - the tarPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • verifyTar

      public boolean verifyTar​(String 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.

      Parameters:
      tarPath - the tarPath argument (not null)
      Returns:
      the result; this method never throws ChilkatException
    • writeTar

      public void writeTar​(String 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.

      Parameters:
      tarPath - the tarPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • writeTarBz2

      public void writeTarBz2​(String 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.

      Parameters:
      bz2Path - the bz2Path argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • writeTarGz

      public void writeTarGz​(String 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.

      Parameters:
      gzPath - the gzPath argument (not null)
      Throws:
      ChilkatException - if the operation fails; ChilkatException.getLastErrorText() says why
    • setProgressListener

      public void setProgressListener​(ProgressListener listener)
      Installs the listener that receives this object's progress events (abortCheck, percentDone, progressInfo) during its long-running methods; replaces any listener or lambda installed before; null removes it.
      Parameters:
      listener - the listener, or null
      Throws:
      IllegalStateException - if called from inside one of this object's own callbacks
    • getProgressListener

      public ProgressListener getProgressListener()
      Returns the installed listener, or null.
      Returns:
      the listener installed with setProgressListener(ProgressListener) or one of the on... methods
    • onAbortCheck

      public void onAbortCheck​(BooleanSupplier callback)
      Installs a listener whose only callback is abortCheck: called every HeartbeatMs milliseconds during a long-running method; return true to abort it. Replaces any listener installed before.
      Parameters:
      callback - the callback, or null to remove the listener
    • onPercentDone

      public void onPercentDone​(IntPredicate callback)
      Installs a listener whose only callback is percentDone: called with the completion percentage (0..100) as a long-running method progresses; return true to abort it. Replaces any listener installed before.
      Parameters:
      callback - the callback, or null to remove the listener
    • onProgressInfo

      public void onProgressInfo​(BiConsumer<String,​String> callback)
      Installs a listener whose only callback is progressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.
      Parameters:
      callback - the callback, or null to remove the listener