The Tar class implements a tar archive utility, compatible with the UNIX tar and untar utilities. The class supports the old v7 tar format. The class also implements gzip compression and can be used to create or decompress .tar.gz archives.
The interface is identical to that of the Zip class, and is the same whether gzip compression is used or not. In particular, the Compress method is used to create tar archives, even if actual compression is not used.
To create a new archive, first set the ArchiveFile property to the name of the archive to be created. Then, specify the files to be compressed either by invoking IncludeFiles, or by adding a new object to the Files collection and setting the values of the FilesDecompressedName and FilesCompressedName. fields. Finally, call the Compress method to create the archive.
To decompress an existing archive, set ArchiveFile to the name of the archive to be decompressed. The ExtractToPath property may be set, and then calling the ExtractAll method will decompress all files in the archive to this path.
For finer control, the Scan method should be used to read the file information stored in the archive. This will fill out the information in the Files collection. The values of FilesDecompressedName may then be changed if desired. Finally, ExtractAll may be used to decompress the entire archive, or Extract may be used for finer control.
tar.gz files may be created or extracted by setting the UseGzipCompression property to true. When Compress is invoked, this will cause all output to be streamed through a gzip compressor as it is written. When extracting or scanning the tar archive will automatically be decompressed and written temporarily to disk. Note that this might cause Scan, Extract, and ExtractAll to operate slowly without firing events.
.gz files may also be compressed or decompressed using the Gzip class.
Example (Creating a Tar File)
ZipControl.ArchiveFile = "c:\test.tar.gz" ZipControl.RecurseSubdirectories = true ZipControl.UseGzipCompression = true ZipControl.IncludeFiles("c:\foo\*") ZipControl.Compress()Example (Extracting from a Tar File)
ZipControl.ArchiveFile = "c:\temp.tar" ZipControl.UseGzipCompression = false ZipControl.ExtractToPath = "c:\extracted\" ZipControl.ExtractAll()
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
|ArchiveFile||The name of the zip, gzip, tar, or jar archive.|
|ExcludedFiles||A list of files to exclude.|
|ExtractToPath||A base path to decompress to.|
|Files||Collection of Tar archive files.|
|OverwriteFiles||Whether or not to overwrite files.|
|RecurseSubdirectories||Whether or not to recurse into subdirectories.|
|TarData||(Decompression only) The tar file contents as a byte array.|
|UseGzipCompression||Whether or not to use gzip compression.|
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
|Abort||Aborts the current operation.|
|Append||Adds a file to an existing archive.|
|Compress||Creates the compressed archive.|
|Config||Sets or retrieves a configuration setting.|
|Delete||Deletes one or more files from an existing archive.|
|Extract||Extracts a single file, directory, or group of files, from the archive.|
|ExtractAll||Extracts all files from the compressed archive.|
|IncludeFiles||Specifies that the indicated files should be added to the archive.|
|Reset||Resets the class.|
|Scan||Scans the compressed archive.|
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
|BeginFile||Fired before each file is processed.|
|EndFile||Fired after each file is processed.|
|Error||Information about non-fatal errors.|
|Overwrite||Fired whenever a file exists and may be overwritten.|
|Progress||Fired as progress is made.|
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
|CheckForFileLocks||If true, the class requests an exclusive lock during initialization.|
|CompressionLevel||The level of compression to use when Gzip compression is enabled.|
|ExcludedAttributes||Attributes of files to be excluded.|
|ExtractFilesOnly||Whether to only extract the files contained within the archive.|
|ExtraNullBytes||Extra null bytes to append to the end of the file.|
|OverwriteReadonlyFiles||Whether to overwrite readonly files.|
|PreserveModifiedTime||Whether or not to preserve the original modified time on extracted files.|
|SetFilePermissions||Whether to set UNIX file permissions.|
|SymlinkAction||That action to take when a symlink is encountered.|
|TempPath||The location where temporary files are created.|
|WriteToProgressEvent||Whether or not to write data to the Progress Event.|
|BuildInfo||Information about the product's build.|
|CodePage||The system code page used for Unicode to Multibyte translations.|
|LicenseInfo||Information about the current license.|
|UseInternalSecurityAPI||Tells the class whether or not to use the system security libraries or an internal implementation.|