Tar Class

Properties   Methods   Events   Configuration Settings   Errors  

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.

Syntax

IPWorksZipTar
IPWorksZipTarSwift

Remarks

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 FileDecompressedName and FileCompressedName. 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 FileDecompressedName may then be changed if desired. Finally, ExtractAll may be used to decompress the entire archive, or Extract may be used for finer control.

Data may be streamed out by setting WriteToProgressEvent to true. Then, the Progress event may be trapped to retrieve the data.

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

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

- archiveFileThe name of the zip, gzip, tar, or jar archive.
- excludedFilesA list of files to exclude.
- extractToPathA base path to decompress to.
- fileCountThe number of records in the File arrays.
- fileCompressedDate:(int)fileIndexThe date and time of the entry, as stored within the archive.
- fileCompressedName:(int)fileIndexThe file name of the current file, as stored inside of the archive.
- fileCompressedSize:(int)fileIndexThe size of the compressed data, as compressed within the archive.
- fileDecompressedName:(int)fileIndexThe name of the file in the archive, as stored on the file system, outside the archive.
- fileDecompressedSize:(int)fileIndexThe size of the file, as decompressed outside the archive.
- fileHardLinkName:(int)fileIndexThe hard link name, for a file that represents a hard link.
- fileInputData:(int)fileIndexWhen This property is set, the class will read in the data from This property instead of reading from the file contained in the DecompressedName property.
- filePermissions:(int)fileIndexThis property contains the UNIX permissions of the file, as stored in the tar archive.
- fileSymLinkName:(int)fileIndexThe symbolic link name, for a file that represents a symbolic link.
- overwriteFilesWhether or not to overwrite files.
- recurseSubdirectoriesWhether or not to recurse into subdirectories.
- tarData(Decompression only) The tar file contents as a byte array.
- useGzipCompressionWhether or not to use gzip compression.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

- abortAborts the current operation.
- appendAdds a file to an existing archive.
- compressCreates the compressed archive.
- configSets or retrieves a configuration setting.
- deleteDeletes one or more files from an existing archive.
- extractExtracts a single file, directory, or group of files, from the archive.
- extractAllExtracts all files from the compressed archive.
- includeFilesSpecifies that the indicated files should be added to the archive.
- resetResets the class.
- scanScans the compressed archive.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

- onBeginFileFired before each file is processed.
- onEndFileFired after each file is processed.
- onErrorInformation about non-fatal errors.
- onOverwriteFired whenever a file exists and may be overwritten.
- onProgressFired as progress is made.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

CheckForFileLocksIf true, the class requests an exclusive lock during initialization.
CompressionLevelThe level of compression to use when Gzip compression is enabled.
ExcludedAttributesAttributes of files to be excluded.
ExtractFilesOnlyWhether to only extract the files contained within the archive.
ExtraNullBytesExtra null bytes to append to the end of the file.
OverwriteReadonlyFilesWhether to overwrite readonly files.
PreserveModifiedTimeWhether or not to preserve the original modified time on extracted files.
SetFilePermissionsWhether to set UNIX file permissions.
SymlinkActionThat action to take when a symlink is encountered.
TempPathThe location where temporary files are created.
WriteToProgressEventWhether or not to write data to the Progress Event.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 iOS Edition - Version 20.0 [Build 8300]