ExtractAll()
|
Previous Top Next |
:ExtractAll([<cTargetRoot>],
|
[<cFileSpec>],
|
[<lCreateDirs>],
|
[<nOverwrite>]) --> nFiles
|
<cTargetRoot>
|
<cTargetRoot> optionally specifies the Target Directory into which all Files and Directories should be extracted. The default value is the Current Directory of the Current Drive.
|
<cFileSpec>
|
<cFileSpec> optionally specifies the desired File Specs for the files that should be extracted from the Zip File, which may include wild card characters like "*" and "?". The default value is "*.*", which means that all files are extracted, if this parameter is omitted.
|
|
NOTE: This parameter is currently completely ignored, and ALWAYS defaults to "*.*", which means that ALWAYS ALL Files are extracted! If you need to extract only some (File) Entries from a Zip File, you need to call the :Extract() method separately for each individual (File) Entry, instead!
|
<lCreateDirs>
|
<lCreateDirs> optionally specifies if Sub-Directories, which are indicated in either the <cTargetRoot> directory or in stored Directory Entries of the Zip File, should be created if they do not exist. The default value is .T. (TRUE), which means that unless this parameter is explicitly set to .F. (FALSE), all specified and included directories will be created, even if they do not contain any (File) Entries.
|
|
NOTE: Only stored (File) Entries that have the "Directory" File Attribute set are considered Directories, and only that kind of Entries will result in Directories being created! The current implementation of this method does NOT create any directories, simply because they are indicated as part of a (File) Entry's File Name!
|
|
If this parameter is set to .F. (FALSE), only those (File) Entries that can be extracted into the <cTargetRoot> (which must already exist in this case) will be saved, while all explicitly stored Directories are not extracted or created -- they will be simply ignored. If <cTargetRoot> does not exist, no (File) Entries are extracted at all!
|
<nOverwrite>
|
<nOverwrite> optionally specifies if existing Files should be replaced or not. The default value is "XBZ_OVERWRITE_OLDER", which means that only existing Files that are Older than the Date/Time Stamp of the (File) Entry are replaced and overwritten, while Files with the same or a newer File Date/Time Stamp are left unchanged. Possible options are the following Define Constants from the XbZLib.ch file:
|
|
|
This method returns the Number of (File) Entries that were actually extracted (without creating an error).
|
Extracts and un-compresses ALL (File) Entries from a Zip File, and saves them in the given <cTargetRoot> directory. Stored Directories -- as well as the <cTargetRoot> directory itself -- will be created if necessary, even though this feature can be disabled, in which case all Files will be created in the <cTargetRoot> directory (which must already exist), while stored Directories are simply ignored.
|
|
Existing Files can either be skipped, always overwritten and replaced or only overwritten and replaced if they are older than the Date/Time Stamp of the to-be-extracted (File) Entry. The File Attributes and the Date/Time Stamp of all extracted Files and Directories are updated as specified in the (File) Entries -- with the exception of the Date/Time Stamp of Directories, which are never changed.
|
|
The process can normally be interrupted by pressing the ESC Key or by creating an xbeP_Close event. Alternatively, if the :CheckEvents Callback is set to a user-defined routine, this behavior can be modified or disabled. See the :CheckEvents and :CancelExtract Callback documentation for more details.
|
|
Future versions may actually use the <cFileSpec> parameter to select or limit the Entries that are actually extracted, or may even allow a Regular Expression or a partial, relative File Name or Path Name match. Another option may be to add a new method, like :ExtractSome(), which might receive an Array (or list) of File Names.
|
|
NOTE: The supported File Attributes are ONLY valid for MS DOS and Windows (FAT/VFAT/NTFS)!
|
Extract all Files and Directories from the Zip File "MyArchive.zip", which is opened in Read-Only mode, into the target directory "C:\NewDir\" and also create all necessary directories, including the target directory, if it does not exist. Files that already exist are only overwritten/replaced, if they are older than the Date/Time Stamp of the (File) Entry in the Zip File. Then close the Zip File:
|
oZip := XbZLibZip():New('MyArchive.zip', XBZ_OPEN_READ)
|
oZip:ExtractAll('C:\NewDir\')
|
oZip:Close()
|