CkTar Ruby Reference Documentation
CkTar
Current Version: 10.0.0
API for creating and extracting TAR archives. Also supports creating and extracting .tar.gz (.tgz), .tar.bz2, and .tar.Z (compressed TAR archives, also known as compressed tarball archives). Can read/write the following TAR formats: (1) GNU tar 1.13.x format, (2) PAX -- POSIX 1003.1-2001 format, (3) USTAR -- POSIX 1003.1-1988 format.
Object Creation
obj = Chilkat::CkTar.new()
Properties
CaptureXmlListing
boolVal = tar.get_CaptureXmlListing();
tar.put_CaptureXmlListing(boolVal);
If true, then untar methods, such as Untar, UntarGz, UntarBz2, and UntarZ, will also capture an XML listing of the contents in the XmlListing property. The format of the XML contained in XmlListing is identical to what is returned by the ListXml method. The default value is false.
topCharset
# ckStr is a CkString
tar.get_Charset(ckStr);
strVal = tar.charset();
tar.put_Charset(strVal);
Character encoding to be used when interpreting filenames within .tar archives for untar operations. The default is "utf-8", and this is typically not changed. (The WriteTar methods always uses utf-8 to store filenames within the TAR archive.)
topDebugLogFilePath
# ckStr is a CkString
tar.get_DebugLogFilePath(ckStr);
strVal = tar.debugLogFilePath();
tar.put_DebugLogFilePath(strVal);
If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.
This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:
- a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
- the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
- there is an internal problem (bug) in the Chilkat code that causes the hang.
DirMode
intVal = tar.get_DirMode();
tar.put_DirMode(intVal);
The directory permissions to used in WriteTar* methods. The default is octal 0755. This is the value to be stored in the "mode" field of each TAR header for a directory entries.
topDirPrefix
# ckStr is a CkString
tar.get_DirPrefix(ckStr);
strVal = tar.dirPrefix();
tar.put_DirPrefix(strVal);
A prefix to be added to each file's path within the TAR archive as it is being created. For example, if this property is set to the string "subdir1", then "subdir1/" will be prepended to each file's path within the TAR.
Note: This property does not apply to files added using the AddFile2 method, which directly specifies the path-in-tar.
topFileMode
intVal = tar.get_FileMode();
tar.put_FileMode(intVal);
The file permissions to used in WriteTar* methods. The default is octal 0644. This is the value to be stored in the "mode" field of each TAR header for a file entries.
topGroupId
intVal = tar.get_GroupId();
tar.put_GroupId(intVal);
The default numerical GID to be stored in each TAR header when writing TAR archives. The default value is 1000.
topGroupName
# ckStr is a CkString
tar.get_GroupName(ckStr);
strVal = tar.groupName();
tar.put_GroupName(strVal);
The default group name to be stored in each TAR header when writing TAR archives. The default value is the logged-on username of the application's process.
topLastErrorHtml
# ckStr is a CkString
tar.get_LastErrorHtml(ckStr);
strVal = tar.lastErrorHtml();
Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
topLastErrorText
# ckStr is a CkString
tar.get_LastErrorText(ckStr);
strVal = tar.lastErrorText();
Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
LastErrorXml
# ckStr is a CkString
tar.get_LastErrorXml(ckStr);
strVal = tar.lastErrorXml();
Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
topLastMethodSuccess
boolVal = tar.get_LastMethodSuccess();
tar.put_LastMethodSuccess(boolVal);
Indicate whether the last method call succeeded or failed. A value of true indicates success, a value of false indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:
- Any method that returns a string.
- Any method returning a Chilkat object, binary bytes, or a date/time.
- Any method returning a standard boolean status value where success = true and failure = false.
- Any method returning an integer where failure is defined by a return value less than zero.
Note: Methods that do not fit the above requirements will always set this property equal to true. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.
topMatchCaseSensitive
boolVal = tar.get_MatchCaseSensitive();
tar.put_MatchCaseSensitive(boolVal);
Determines whether pattern matching for the MustMatch and MustNotMatch properties is case-sensitive or not. The default value is false.
topMustMatch
# ckStr is a CkString
tar.get_MustMatch(ckStr);
strVal = tar.mustMatch();
tar.put_MustMatch(strVal);
If set, then file paths must match this pattern when creating TAR archives, or when extracting from TAR archives. If a file does not match, it will not be included when creating a TAR, or it will not be extracted when extracting from a TAR. This property also applies to methods that create or extract from compressed TAR archives.
The must-match pattern may include 0 or more asterisk characters, each of which represents 0 or more of any character. For example, the pattern "*.txt" causes only .txt files to be included or extracted. The default value is an empty string, indicating that all files are implicitly matched.
topMustNotMatch
# ckStr is a CkString
tar.get_MustNotMatch(ckStr);
strVal = tar.mustNotMatch();
tar.put_MustNotMatch(strVal);
If set, then file paths must NOT match this pattern when creating TAR archives, or when extracting from TAR archives. If a file path matches, it will not be included when creating a TAR, or it will not be extracted when extracting from a TAR. This property also applies to methods that create or extract from compressed TAR archives.
The must-not-match pattern may include 0 or more asterisk characters, each of which represents 0 or more of any character. For example, the pattern "*.obj" causes all .obj files to be skipped. The default value is an empty string, indicating that no files are skipped.
topNoAbsolutePaths
boolVal = tar.get_NoAbsolutePaths();
tar.put_NoAbsolutePaths(boolVal);
If true, then absolute paths are converted to relative paths by removing the leading "/" or "\" character when untarring. This protects your system from unknowingly untarring files into important system directories, such as C:\Windows\system32. The default value is true.
topNumDirRoots
intVal = tar.get_NumDirRoots();
The total number of directory roots set by calling AddDirRoot (i.e. the number of times AddDirRoot was called by the application). A TAR archive is created by calling AddDirRoot for one or more directory tree roots, followed by a single call to WriteTar (or WriteTarBz2, WriteTarGz, WriteTarZ). This allows for TAR archives containing multiple directory trees to be created.
topScriptFileMode
intVal = tar.get_ScriptFileMode();
tar.put_ScriptFileMode(intVal);
The file permissions to used in WriteTar* methods for shell script files (.sh, .csh, .bash, .bsh). The default is octal 0755. This is the value to be stored in the "mode" field of each TAR header for a file entries.
topSuppressOutput
boolVal = tar.get_SuppressOutput();
tar.put_SuppressOutput(boolVal);
If true, then untar methods, such as Untar, UntarGz, UntarBz2, and UntarZ, do not produce any output. Setting this value equal to true is useful when the CaptureXmlListing is also set to true, which enables an application to get the contents of a TAR archive without extracting. The default value is false.
topUntarCaseSensitive
boolVal = tar.get_UntarCaseSensitive();
tar.put_UntarCaseSensitive(boolVal);
This property is deprecated. Applications should instead use the MatchCaseSensitive property. Until this property is officially removed, it will behave the same as the MatchCaseSensitive property.
topUntarDebugLog
boolVal = tar.get_UntarDebugLog();
tar.put_UntarDebugLog(boolVal);
Similar to the VerboseLogging property. If set to true, then information about each file/directory extracted in an untar method call is logged to LastErrorText (or LastErrorXml / LastErrorHtml). The default value is false.
topUntarDiscardPaths
boolVal = tar.get_UntarDiscardPaths();
tar.put_UntarDiscardPaths(boolVal);
If true, then discard all path information when untarring. This causes all files to be untarred into a single directory. The default value is false.
topUntarFromDir
# ckStr is a CkString
tar.get_UntarFromDir(ckStr);
strVal = tar.untarFromDir();
tar.put_UntarFromDir(strVal);
The directory path where files are extracted when untarring. The default value is ".", meaning that the current working directory of the calling process is used. If UntarDiscardPaths is set, then all files are untarred into this directory. Otherwise, the untar operation will re-create a directory tree rooted in this directory.
topUntarMaxCount
intVal = tar.get_UntarMaxCount();
tar.put_UntarMaxCount(intVal);
Limits the number of files extracted during an untar to this count. The default value is 0 to indicate no maximum. To untar a single file, one might set the UntarMatchPattern such that it will match only the file to be extracted, and also set UntarMaxCount equal to 1. This causes an untar to scan the TAR archive until it finds the matching file, extract it, and then return.
topUserId
intVal = tar.get_UserId();
tar.put_UserId(intVal);
The default numerical UID to be stored in each TAR header when writing TAR archives. The default value is 1000.
topUserName
# ckStr is a CkString
tar.get_UserName(ckStr);
strVal = tar.userName();
tar.put_UserName(strVal);
The default user name to be stored in each TAR header when writing TAR archives. The default value is the logged-on username of the application's process.
topUtf8
boolVal = tar.get_Utf8();
tar.put_Utf8(boolVal);
When set to true, all "const char *" arguments are interpreted as utf-8 strings. If set to false (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to true, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to false, all "const char *" return values are ANSI strings.
topVerboseLogging
boolVal = tar.get_VerboseLogging();
tar.put_VerboseLogging(boolVal);
If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
topVersion
WriteFormat
# ckStr is a CkString
tar.get_WriteFormat(ckStr);
strVal = tar.writeFormat();
tar.put_WriteFormat(strVal);
The TAR format to use when writing a TAR archive. Valid values are "gnu", "pax", and "ustar". The default value is "gnu".
topXmlListing
# ckStr is a CkString
tar.get_XmlListing(ckStr);
strVal = tar.xmlListing();
tar.put_XmlListing(strVal);
Contains the XML listing of the contents of the TAR archive for the last untar method call (such as Untar, UntarGz, etc.) where the CaptureXmlListing property was set to true.
topMethods
AddDirRoot
status = tar.AddDirRoot(dirPath);
Adds a directory tree to be included in the next call to one of the WriteTar* methods. To include multiple directory trees in a .tar, call AddDirRoot multiple times followed by a single call to WriteTar.
Returns true for success, false for failure.
topAddDirRoot2
# rootPath is a string
status = tar.AddDirRoot2(rootPrefix, rootPath);
Adds a directory tree to be included in the next call to one of the WriteTar* methods. To include multiple directory trees in a .tar, call AddDirRoot2 (and/or AddDirRoot) multiple times followed by a single call to WriteTar.
The rootPrefix adds a prefix to the path in the TAR for all files added under this root. The rootPrefix should not end with a forward-slash char. For example: This is good: "abc/123", but this is not good: "abc/123/". If the DirPrefix property is also set, its prefix will added first.
Returns true for success, false for failure.
AddFile
status = tar.AddFile(path);
Adds a local file to be included in the next call to one of the WriteTar* methods. To include multiple files or directory trees in a .tar, call AddFile/AddDirRoot multiple times followed by a single call to WriteTar (or WriteTarGz, or WriteTarBz2).
Returns true for success, false for failure.
topAddFile2
# pathWithinTar is a string
status = tar.AddFile2(filePath, pathWithinTar);
Adds a local file to be included in the next call to one of the WriteTar* methods. Allows for the path within the TAR to be specified. To include multiple files or directory trees in a .tar, call AddFile/AddFile2/AddDirRoot multiple times followed by a single call to WriteTar (or WriteTarGz, or WriteTarBz2).
Note: The DirPrefix property does not apply to files added via this method because this method explicilty specifies the path-in-tar.
Returns true for success, false for failure.
topClearDirRootsAndFiles
Clears all directory roots and files previously added by calls to AddDirRoot, AddDirRoot2, AddFile, and AddFile2.
Returns true for success, false for failure.
topCreateDeb
# dataPath is a string
# debPath is a string
status = tar.CreateDeb(controlPath, dataPath, debPath);
Creates a .deb Debian binary package archive from a control.tar.gz and data.tar.gz. The controlPath is the path to the control.tar.gz file (or equivalent), and the dataPath is the path to the data.tar.gz file. The output file path (.deb) is specified in debPath.
Returns true for success, false for failure.
topGetDirRoot
# outStr is a CkString (output)
status = tar.GetDirRoot(index, outStr);
retStr = tar.getDirRoot(index);
Returns the value of the Nth directory root. For example, if an application calls AddDirRoot twice, then the NumDirRoots property would have a value of 2, and GetDirRoot(0) would return the path passed to AddDirRoot in the 1st call, and GetDirRoot(1) would return the directory path in the 2nd call to AddDirRoot.
Returns true for success, false for failure.
topListXml
# outStr is a CkString (output)
status = tar.ListXml(tarPath, outStr);
retStr = tar.listXml(tarPath);
Scans a TAR archive and returns XML detailing the files and directories found within the TAR.
Returns true for success, false for failure.
topListXmlAsync (1)
Creates an asynchronous task to call the ListXml method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topLoadTaskCaller
Untar
retInt = tar.Untar(tarPath);
Extracts the files and directories from a TAR archive, reconstructing the directory tree(s) in the local filesystem. The files are extracted to the directory specified by the UntarFromDir property. Returns the number of files and directories extracted, or -1 for failure.
UntarAsync (1)
Creates an asynchronous task to call the Untar method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topUntarBz2
status = tar.UntarBz2(tarPath);
Extracts the files and directories from a tar.bz2 (or tar.bzip2) archive, reconstructing the directory tree(s) in the local filesystem. The files are extracted to the directory specified by the UntarFromDir property.
Returns true for success, false for failure.
UntarBz2Async (1)
Creates an asynchronous task to call the UntarBz2 method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topUntarFirstMatchingToBd
# matchPattern is a string
# bd is a CkBinData
status = tar.UntarFirstMatchingToBd(tarPath, matchPattern, bd);
Untars the first file matching the matchPattern into bd.
Returns true for success, false for failure.
topUntarFirstMatchingToMemory
# matchPattern is a string
# outBytes is a CkByteData (output)
status = tar.UntarFirstMatchingToMemory(tarFileBytes, matchPattern, outData);
Memory-to-memory untar. The first file matching the matchPattern is extracted and returned.
Returns true for success, false for failure.
topUntarFromMemory
Extracts the files and directories from an in-memory TAR archive, reconstructing the directory tree(s) in the local filesystem. The files are extracted to the directory specified by the UntarFromDir property. Returns the number of files and directories extracted, or -1 for failure.
topUntarFromMemoryAsync (1)
# tarFileBytes is a CkByteData
ret_task = tar.UntarFromMemoryAsync(tarFileBytes);
Creates an asynchronous task to call the UntarFromMemory method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topUntarGz
status = tar.UntarGz(tarPath);
Extracts the files and directories from a tar.gz (or tar.gzip) archive, reconstructing the directory tree(s) in the local filesystem. The files are extracted to the directory specified by the UntarFromDir property.
Returns true for success, false for failure.
UntarGzAsync (1)
Creates an asynchronous task to call the UntarGz method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topUntarZ
status = tar.UntarZ(tarPath);
Extracts the files and directories from a tar.Z archive, reconstructing the directory tree(s) in the local filesystem. The files are extracted to the directory specified by the UntarFromDir property.
Returns true for success, false for failure.
UntarZAsync (1)
Creates an asynchronous task to call the UntarZ method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topVerifyTar
retBool = tar.VerifyTar(tarPath);
Verifies that a TAR archive is valid. This method opens the TAR archive and scans the entire file by walking the TAR headers. Returns true if no errors were found. Otherwise returns false.
topVerifyTarAsync (1)
Creates an asynchronous task to call the VerifyTar method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topWriteTar
status = tar.WriteTar(tarPath);
Writes a TAR archive. The directory trees previously added by calling AddDirRoot one or more times are included in the output TAR archive.
Returns true for success, false for failure.
WriteTarAsync (1)
Creates an asynchronous task to call the WriteTar method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topWriteTarBz2
status = tar.WriteTarBz2(bz2Path);
Writes a .tar.bz2 compressed TAR archive. The directory trees previously added by calling AddDirRoot one or more times are included in the output file.
Returns true for success, false for failure.
WriteTarBz2Async (1)
Creates an asynchronous task to call the WriteTarBz2 method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
topWriteTarGz
status = tar.WriteTarGz(gzPath);
Writes a .tar.gz (also known as .tgz) compressed TAR archive. The directory trees previously added by calling AddDirRoot one or more times are included in the output file.
Returns true for success, false for failure.
WriteTarGzAsync (1)
Creates an asynchronous task to call the WriteTarGz method with the arguments provided. (Async methods are available starting in Chilkat v9.5.0.52.)
Returns nil on failure
top