AddDir()
|
Previous Top Next |
:AddDir([<cFileSpec>],
|
[<cRootDir>],
|
[<cAttribs>],
|
[<lSubDirs>],
|
[<lAddPath>],
|
[<lAddNote>]) --> nQuit
|
<cFileSpec>
|
<cFileSpec> optionally specifies the desired File Specs, which may include wild card characters like "*" and "?", for the files that should be added to the Zip File. The default value is "*.*", which means that all files will be added (or updated).
|
<cRootDir>
|
<cRootDir> optionally specifies the Source Directory from which the files should be read. The default value is the Current Directory of the Current Drive.
|
<cAttribs>
|
<cAttribs> optionally specifies the File Attributes for the files that should be added to the Zip File. The default value is "HS", which means that all files, including Hidden and System files are added.
|
|
If the specified File Attributes include the letter "D" (which stands for Directory), all Sub-Directories are also included, even if the <lSubDirs> parameter is not set and even if it was set to .F. (FALSE)!
|
<lSubDirs>
|
<lSubDirs> optionally determines if Sub-Directories (as well as all the files that adhere to the <cFileSpec> parameter and that are located inside those Sub-Directories) are also included in the Zip File. The default value is .F. (FALSE), unless the <cAttribs> parameter contains a "D", in which case the default value is always .T. (TRUE), even if .F. (FALSE) was explicitly specified for <lSubDirs>!
|
|
If this parameter is set to .F. (FALSE), only files that are located in the <cRootDir> directory will be added, otherwise Sub-Directories are also included and searched for valid files.
|
<lAddPath>
|
<lAddPath> optionally determines if relative Path Names, including all the Sub-Directory names, should be saved in the Zip File, or if only the File Name itself, without any Path information is saved. The default value is .F. (FALSE), unless <lSubDirs> is set to .T. (TRUE), in which case the default value is always .T. (TRUE), even if .F. (FALSE) was explicitly specified for <lAddPath>!
|
|
If this parameter is set to .F. (FALSE), adding files from different directories that have the same File Name would be impossible, as all files with the same file name would replace previously added ones, instead of being added as new files!
|
<lAddNote>
|
<lAddNote> optionally determines if the full (absolute) Path Name of each file is automatically added as a File Comment to each Zip File Entry. The default value is .F. (FALSE), which means that the File Comments of all Entries are left unchanged (or empty).
|
This method returns the Completion Status of the process. Possible values are the following Define Constants from the XbZLib.ch file:
|
|
|
This method adds multiple files to the open Zip File, possibly including complete sub-directory trees and valid files from sub-directories. The Zip File itself -- as well as the possibly specified Log File -- will be skipped and not added to the Zip File -- unless they appear to be located on a different drive, due to the selected names or paths.
|
|
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 :CancelAdd Callback documentation for more details.
|
|
Future versions may allow the adding/replacing of only Newer Files, rather than always All Files. This might speed up the process for large Zip Files, especially with many entries. Another option might be to only add Directories to the Zip File, if they contain (valid) Files (or Sub-Directories) that are also added to the Zip File, rather than all Sub-Directories, even if they are empty (or do not contain valid files).
|
|
NOTE: The supported File Attributes are ONLY valid for MS DOS and Windows (FAT/VFAT/NTFS)!
|
Add all "*.db?" files from the "D:\Data" directory and all its Sub-Directories (that do NOT have the "R", "H", or "S" File Attribute set) to the Zip File "MyArchive.zip", and also store ALL Sub-Directories and save the relative Path Names of all included Files and Directories. If any of the Files or Directories already exist in the open Zip File, the existing File Entry will be replaced, otherwise a new File Entry will be added. Then save and close the updated Zip File:
|
|
oZip:New('MyArchive.zip')
|
if oZip:IsOpen(.t.)
|
oZip:AddDir('*.db?', 'D:\Data', 'A', .t.)
|
endif
|
oZip:Close()
|