Unit Lzh_btch |
Classes |
Functions |
ForceDirectory - Replacement for the ForceDirectories function of Delphi which can } { cause a stack overflow if you specify an invalid directory
GetItem - Utility functions } { GetItem returns an item from a string that is built up using sSep } { as a separator string.
Register - Registers the TLZHBatch component
Catenate the archive directory and the temporary archive } { and rename it to the file specified in the ArchiveFileName } { property
Types |
TArchiveMode
TCollectAction
TCollectErrorAction
TCollectErrorEvent
TCollectingEvent
TDirectoryInfo
TDoneCollectingEvent
TFileExistAction
TFileExistEvent
TProgressEvent
TString
Constants |
Variables |
Functions |
The TExtraInfo class is used to be able to store the offset of } { a file inside the archive and to be able to select or deselect it } { without the user seeing all of this
Catenate the archive directory and the temporary archive } { and rename it to the file specified in the ArchiveFileName } { property
Types |
TArchiveMode = (amNew, amAdd);
TCollectAction = (caAccept, caReject, caCancel);
TCollectErrorAction = (ceReject, ceCancel);
TCollectErrorEvent = procedure(Sender : TObject; const FileName : String; var Action: TCollectErrorAction) of object
TCollectingEvent = procedure(Sender : TObject; const FileName : String; var Action: TCollectAction) of object
TDirectoryInfo = (diNone, diRelativePath, diFullPath);
TDoneCollectingEvent = procedure(Sender : TObject; const NrOfFiles : Integer; const TotalSize : Longint; var Cancel : Boolean) of object
TFileExistAction = (eaOverwrite, eaSkip, eaCancel);
TFileExistEvent = procedure(Sender : TObject; const FileName : String; var Action : TFileExistAction) of object
TProgressEvent = procedure(Sender : TObject; const FileName : String; const FileBytesWritten, FileBytes, TotalBytesWritten, TotalBytes: Longint; var Cancel : Boolean) of object
TString = String[255]Date: October 28, 1996 Programmer: Arjen Broeze Version: 1.1 E-Mail: arjen@shear.iaf.nl, ab@nedap.nl This unit implements a component which allows the user to compress or decompress a batch of files specified by one or more wildcards. It is built upon the excellent LZHCompressor component by Douglas P. Webb. The four key methods that can be invoked are 'Compress', 'Decompress', 'DecompressSelected' and 'DeleteSelected'. Instead of specifying the routines for reading and writing the bytes, this components accepts a list of files or wildcards and compresses all these into a single file, specified in the ArchiveFileName property. As soon as you specify an archive filename, it's directory is read and stored in the (read-only) stringlist ArchiveDirectory. To decompress files, call the 'Decompress' method (which decompresses all files in the archive) or call the 'DecompressSelected' method, which decompresses only those files that are marked as 'Selected'. To delete files from an existing archive, select them using the Selected property array and call the 'DeleteSelected' method. Following is a list of the key properties, events and methods: Properties ArchiveDirectory read-only stringlist that contains the directory of the archive specified in the ArchiveFileName property. Every string in the list consists of 5 items (filename, uncompressed size, compressed size, attributes and filedate) all separated by a TAB character (#9). This allows you to put them in a tabbed listbox or an owner draw listbox pretty easily. DirectoryInfo Determines how directory information is stored inside the archive. Possible values are: diNone no directory information stored (default) diRelativePath paths are stored relative to the root (specified in the RootDirectory property) diFullPath stores the full path (without the drivename) InputFiles Stringlist containing all the files to put into an archive. Every entry can contain wildcards and (if possible) will be searched relative to the directory specified in the RootDirectory property. ArchiveFileName Fully qualified path to an archive file. Hint: do not use the LZH extension for your archives. Although the LZHCompressor component does compress using the same method as the LHA program, the fileheader for files generated by this component and the LHA fileheader are completely different. ArchiveMode Specifies the mode when compressing file. Set to amAdd to add files to an existing archive, amNew to create a new archive and overwrite the old one. If the archive doesn't exist amAdd will have no effect. CompressedSize Compressed size of all files in the archive file (see also TotalSize). Useful for calculating average compression. OutputDirectory Directory to output the files to when decompressing. OverwriteExisting Specifies wether or not to overwrite existing files (see also OnFileExist event). Default True. RootDirectory Root directory for searching files to put into an archive. RecurseDirectories If True, every entry in InputFiles will cause the component to look in all subdirectories. Defaults to False. See the example for details. RestoreAttributes If True, the file attributes of files are restored after decompression. Default False. RestoreFileDate If True, the file date and time of files are restored after decompression. Default False. UseDirectoryNames Specifies wether or not to use the directorynames stored inside the archive when decompressing. Selected[Index] Specified which files are to be included in the next decompress or delete operation (see the DecompressSelected and DeleteSelected methods). The index in the Selected property array corresponds to the index in the ArchiveDirectory property. That is, if you set Selected[i] to True, the file in ArchiveDirectory.Items[3] will be selected for decompression or deletion. TotalSize Total size of all files in the archive (see also CompressedSize). Useful for calculating average compression ValidArchive Read-only. Specifies wether or not the archive specified by the ArchiveFilename property is a valid archive. Events OnCollecting When compressing, all files are collected first to get file information and total filesize (needed for OnProgress event. Allows you to review every file before any disk writes are made. By setting the Action variable you can control what to do. Possible values are: caAccept Accept the current file (default) caReject Reject the current file caCancel Cancels the compression operation OnCollectError Occurs when a file cannot be opened for reading. By setting the Action variable you can control what to do. Possible values are: ceReject Reject the file that cannot be opened (default) ceCancel Cancels the compression operation OnDoneCollecting Occurs when all files have been processed but before any disk writes have been made. Supplies the total number of files and the total size. Setting the Cancel variable to True cancels the compression operation. OnFileExist Occurs only if OverwriteExisting is set to False. By setting the Action variable to eaOverwrite (default) the file will be overwritten, setting it to eaCancel cancels the current operation. eaSkip skips the current files. When compressing and an existing archivefile is found eaSkip is the same as eaCancel. If not assigned, the EFileExist exception will be raised. OnProgress Occurs during compression and decompression. Specifies the current file, the number of bytes done and total nytes per file and total number of files. See the example for a demonstration. Methods Compress Compresses all files specified in the InputFile property into the archive specified by the ArchiveFileName property. If ArchiveMode is set to amAdd files will be added to an existing archive, otherwise a new archive is created (default). Decompress Decompresses all files in the archive specified by the ArchiveFileName property into the directory specified in the OutputDirectory property. DecompressSelected Decompresses all the files from the archive directory that are marked selected. See the Selected property for details. DeleteSelected Deletes all the files from the archive directory that are marked selected. Essentially writes a new archive without the files marked as Selected. See the Selected property for details.
Constants |
Variables |