PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Use condition
  • Compression level
  • Error codes
  • Adding a file that is already found in the archive
  • Index of files in the archive
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Adds a list of files (of any type) into an archive in ZIP, CAB, WDZ or 7z, TAR ou TGZ (TAR.GZ) format and compresses it. This function is faster than <zipArchive variable>.AddFile run for each file.
Versions 18 and later
WEBDEV - Server codeWindows This function now supports the 7z format.
New in version 18
WEBDEV - Server codeWindows This function now supports the 7z format.
WEBDEV - Server codeWindows This function now supports the 7z format.
Versions 21 and later
WEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
New in version 21
WEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
WEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
Example
WEBDEV - Server codeAjax
// Création d'une archive et ajout d'un élément
// Avec jauge affichée dans un champ Jauge
MonArchive est un zipArchive
NumErrZip est un entier
 
NumErrZip = MonArchive.Crée("C:\Doc\Archive\ficArchive.zip")
SI NumErrZip = 0 ALORS
NumErrZip = MonArchive.AjouteListeFichier("C:\doc\Image\Maison.BMP" + RC + ...
"C:\Mes Projets\WDStock\WDStock.wdp", zipDisque, JAUGE_Progression)
SI NumErrZip <> 0 ALORS
Erreur(zipMsgErreur(NumErrZip))
FIN
MonArchive.Ferme()
SINON
Erreur(zipMsgErreur(NumErrZip))
FIN
Syntax

Adding a list of files (files separated by CR) Hide the details

<Result> = <Archive>.AddFileList(<Path of files to add> [, <Path section to store> [, <Progress>]])
<Result>: Integer
  • 0 if the addition was performed,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
<Archive>: zipArchive variable
Name of an Variable of type zipArchive corresponding to the archive in which the files must be added.
<Path of files to add>: Character string
Name and path of files to add into the archive, separated by CR characters. These paths can be full paths or paths relative to the current directory. The size of each path must not exceed 260 characters.
The size of each file must not exceed 4 GB. Otherwise, an error occurs.
You cannot use wildcard characters.
<Path section to store>: Optional constant
Versions 18 and later
Indicates the section of file paths that must be stored in the archive. This parameter is taken into account for the files for which <Path to store> was not specified.
zipNoneStores the file name and extension. For example: FileName.pdf
zipDirectoryStores the different directories found in the file path as well as the file name and extension. For example: \Directory\Files\FileName.pdf
zipDrive
(Default value)
Store the full and absolute path of file (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf
For the ZIP format: This constant has no effect.
For the 7z format: This constant and zipDirectory will have the same effect
Linux This constant is not available as there is no root for the drive.

If you are using an archive in .CAB format, only the zipNone constant is taken into account. Indeed, the .CAB format cannot be used to store the paths inside the archive.
New in version 18
Indicates the section of file paths that must be stored in the archive. This parameter is taken into account for the files for which <Path to store> was not specified.
zipNoneStores the file name and extension. For example: FileName.pdf
zipDirectoryStores the different directories found in the file path as well as the file name and extension. For example: \Directory\Files\FileName.pdf
zipDrive
(Default value)
Store the full and absolute path of file (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf
For the ZIP format: This constant has no effect.
For the 7z format: This constant and zipDirectory will have the same effect
Linux This constant is not available as there is no root for the drive.

If you are using an archive in .CAB format, only the zipNone constant is taken into account. Indeed, the .CAB format cannot be used to store the paths inside the archive.
Indicates the section of file paths that must be stored in the archive. This parameter is taken into account for the files for which <Path to store> was not specified.
zipNoneStores the file name and extension. For example: FileName.pdf
zipDirectoryStores the different directories found in the file path as well as the file name and extension. For example: \Directory\Files\FileName.pdf
zipDrive
(Default value)
Store the full and absolute path of file (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf
For the ZIP format: This constant has no effect.
For the 7z format: This constant and zipDirectory will have the same effect
Linux This constant is not available as there is no root for the drive.

If you are using an archive in .CAB format, only the zipNone constant is taken into account. Indeed, the .CAB format cannot be used to store the paths inside the archive.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
New in version 21
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.

Adding a list of files found in an array Hide the details

<Result> = <Archive>.AddFileList(<List of files> [, <Progress>])
<Result>: Integer
  • 0 if the addition was performed,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
<Archive>: zipArchive variable
Name of an Variable of type zipArchive corresponding to the archive in which the files must be added.
<List of files>: Array of zipArchivedFile variables
Array of zipArchivedFile variables used to find out the characteristics of the files to add.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
New in version 21
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Remarks

Use condition

Adding files into an archive can be performed if:
  • The archive exists (archives are created using <zipArchive variable>.Create).
  • The archive is accessible in read/write.
  • The archive is a single-part archive.
  • The size of the file is less than 4 GB.
Caution:
  • The full path of each file is stored in the archives in ZIP or WDZ format.
  • Archives in CAB format: The files must be added immediately after the archive creation. This format cannot be used to add files into an existing archive.
  • Archives in RAR format: This function is not available.
  • Archives in 7z format: The archive is fully compressed each time the <zipArchive variable>.AddFileListfunction is called.
The maximum number of files that can be included:
  • in a WDZ file: 232-1.
  • in a ZIP file: 65535.
  • in a CAB file: 65535.
Reminder:
  • Linux Only ZIP, TAR and TGZ (TAR.GZ) archives are available.

Compression level

The files added into an archive in Zip format are compressed by default. The compression level of files added into an archive can be modified by zipCompressionLevel.

Error codes

The following error codes are returned:
  • 1: The path passed as parameter does not exist.
  • 2: Access denied: the user has no sufficient rights or the file is currently used. If the file to insert is an HFSQL data file, it must be closed by the following code:
    HFerme(<Nom Fichier>)
    Multitâche(<Attente>) // Attend la fermeture effective du fichier
  • 3: The archive is corrupted.
  • 4: The path does not exist in the archive.
  • 5: Unable to write into the archive.
  • 7: The file is already found in the archive.
  • 8: An archive cannot be added to itself. For example, "MyArchive" cannot be added to "MyArchive".
The message corresponding to the error code is returned by zipMsgError.

Adding a file that is already found in the archive

An error occurs when adding a file that is already found in the archive. A file is identified by its stored path. Therefore, two files with the same name and with the same relative path cannot be added into an archive.

Index of files in the archive

When a file is added into an archive, an index is automatically assigned to the file. This index corresponds to the order in which the files are included in the archive. To select a file in the archive, you can use:
  • The subscript of the element (note: the subscript of an element can be known thanks to the zipFindFile function).
  • The stored path of element.
Component: wd270zip.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment