This function allows you to extract files from archives from files compressed using the ibec_CompressFile function.
Archives currently supported by ibec_DecompressFile function include the following formats:
ZIP, ZIP SFX, ZOO, ZOO SFX, RAR, ARJ, ARJ SFX, ARC, ARC SFX, ACE, CAB, HA, JAR (JavaSoft java format), LHA, LHA SFX, LZH, LZH SFX, PAK, PAK SFX, TAR, GZIP, Z, BH, BH SFX.
function ibec_DecompressFile(ArcName : string; FileSpec : string; ExcludeFileSpec : string; TargetDir : string; Options : string; CallbackBlock : string) : variant;
ibec_DecompressFile returns the number of extracted files if there were no errors. Otherwise it returns NULL.
ArcName | Defines the file name of the archive from which to extract files. |
---|---|
FileSpec | See description of corresponding parameter for ibec_CompressFile. |
ExcludeFileSpec | See description of corresponding parameter for ibec_CompressFile. |
TargetDir | Defines the directory in which the files from an archive are to be extracted. If this parameter does not contain a blank string, then the UseStoredDirs option is automatically set to False. To extract files into original directories, this property must be blank and the UseStoredDirs option set to True. |
Options | List of additional options, which must be separated with semicolon. Possible options are: Password, UseStoredDirs, DateAttribute, RecurseDirs, onfirmOverwrites, OverwriteMode, RestoreFileAttributes. See detailed description of each option below. |
CallbackBlock | A call-back EXECUTE IBEBLOCKIBEBlock]] which will be executed for some events during the decompression process. The call-back IBEBlock must have at least one input parameter, which will be used to pass array of event values. If there is no call-back block use NULL or an empty string as a value of this parameter. |
Password= <password> | Use the password option to add encrypted files to a ZIP and BlackHole archives or extract encrypted files from ones. If the value of this property is not blank, the value will be used as the password for encryption/decryption. |
---|---|
DateAttribute= FileDate - SysDate - MaxFileDate | Use this option to define a file's date when extracted to disk. Use this property to define a file's date to be stored into an archive. Possible values: |
* FileDate - set the extracted file's date using the date stored in the archive; store the date using the disk file's date being compressed. | * FileDate - set the extracted file's date using the date stored in the archive; store the date using the disk file's date being compressed. |
* SysDate - set the extracted file's date using the systems date/time; store the date using the current system's date. | * SysDate - set the extracted file's date using the systems date/time; store the date using the current system's date. |
* MaxFileDate - set the extracted file's date using the date from the newest file in the archive; store the date using the newest file's date matching FileSpec. | * MaxFileDate - set the extracted file's date using the date from the newest file in the archive; store the date using the newest file's date matching FileSpec. |
RecurseDirs | TRUE - FALSE - Use this option to recurse sub-directories for files matching the FileSpec parameter. The default value is False. |
OverwriteMode | Skip - Overwrite - Use the OverwriteMode property to either skip or overwrite files that already exist on disk. The default value is Skip. |
ConfirmOverwrites | TRUE - FALSE - The ConfirmOverwrites option is directly related to the OverwriteMode option. The default value is False. This option is reserved for future use, please don't change it yet! |
RestoreFileAttributes | TRUE - FALSE - When True, this sets an extracted file's attribute to the setting stored in the compressed header for that file. The default value is True. |
UseStoredDirs | TRUE - FALSE - When set to False, this uses the current directory to extract files into, if the TargetDir property is blank. When set to True, the default is the current directory information existing in regard to the internal compressed file. The default value is False. |
execute ibeblock as begin cbb = 'execute ibeblock (Vals variant) as begin EventName = Vals[''EVENT'']; Action = Vals[''ACTION'']; File name = Vals[''FILE NAME'']; if (Action = ''COMPRESS'') then sPref = ''Adding ''; else sPref = ''Extracting ''; if (EventName = ''FILEBEGIN'') then ibec_Progress(sPref + File name + ''...''); else if (EventName = ''PROGRESS'') then begin iBytes = Vals[''BYFILE'']; if (ibec_Mod(iBytes, 5) = 0) then ibec_Progress(sPref + File name + ''... '' + ibec_Cast(iBytes, __typeString) + ''%''); end; end'; ibec_DecodeDate(ibec_Now(), iYear, iMonth, iDay); ArcName = 'E:\IBE_' + ibec_Cast(iYear, __typeString) + '_' + ibec_Cast(iMonth, __typeString) + '_' + ibec_Cast(iDay, __typeString) + '.zip'; if (ibec_FileExists(ArcName)) then begin ibec_ShowMessage('Nothing to do.'); Exit; end; -- Decompressing FileSpec = '*.*'; ibec_ForceDirectories('E:\TestDecompress\'); MyVar = ibec_DecompressFile(ArcName, FileSpec, '', 'E:\TestDecompress\', '', cbb); end;