Extract
PowerScript function
Description
Extracts the compressed archive or data stream.
Applies to
ExtractorObject objects
Syntax 1: Extracts the compressed
archive
|
1 |
objectname.Extract ( string source, string target ) |
Syntax 2: Extracts the specified files (or
folders) from the specified package
|
1 |
objectname.Extract ( string source, string items[], string target ) |
Syntax 3: Extracts the specified file from the
compressed package into a blob
|
1 |
objectname.Extract ( string source, string item, ref blob target ) |
Syntax 4: Extracts the compressed blob
data
|
1 |
objectname.Extract ( blob source, ref blob target {, ArchiveFormat format }) |
|
Argument |
Description |
|---|---|
|
objectname |
The name of the ExtractorObject object. |
|
source |
A string whose value is the full directory of the Or a blob whose value is the compressed data |
|
items[] |
The specified files (or folders) to extract. The files (or If you specify a single file in a subfolder, the method |
|
item |
The specified file to extract. You can only extract one |
|
target |
A string whose value is the directory where the compressed Or a blob where the decompression results will be |
|
format (optional) |
A value of the enumerated datatype ArchiveFormat
|
Usage
The Extract method determines the archive format according to the
file extension; therefore, if the file extension has been changed manually
(for example, from .rar to .zip), the Extract method will fail to extract
the file and will return the error code -10.
When extracting to a blob data, you can only extract one file
(rather than a folder or multiple files) into a blob.
Return value
Integer.
Returns the following value. If any argument’s value is null, the
method returns null.
1 — Success
-1 — A general error occurred.
-2 — The password entered is illegal.
-3 — The operation is not supported for the source file
format.
-4 — The task thread is aborted.
-5 — A task thread is currently running.
-6 — No password is entered. You must enter the password.
-7 — The password is incorrect.
-8 — Failed to get new memory when saving the decompressed
file.
-9 — Failed to read the compressed file.
-10 — Unrecognized format or the encrypted file name option is used
when compressing the document.
-11 — Access denied when extracting the archive.
-12 — The compressed file does not exist.
-13 — The directory where the decompressed file will be saved does
not exist.
-14 — Failed to extract the compressed file.
-15 — The file to be decompressed is not in the package.
-16 — The current operation does not support the folder
decompression.
Example 1
This example demonstrates how to extract a compressed
package.
|
1 2 3 4 5 6 7 |
ExtractorObject lnv_extractor Integer li_return string ls_source, ls_target ls_source = "D: estcom.7Z" ls_target = "D: estextract" lnv_extractor = Create ExtractorObject li_return = lnv_extractor.extract (ls_source, ls_target) |
Example 2
This example demonstrates how to compress and extract a blob
data.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
CompressorObject lnv_compress ExtractorObject lnv_extractor Integer li_return blob lb_source, lb_target, lb_extract lb_source = blob ("A123456") lnv_compress = create CompressorObject lnv_extractor = create ExtractorObject li_return = lnv_compress.Compress (lb_source, lb_target, ArchiveFormat7Zip!) if li_return = 1 then li_return = lnv_extractor.extract (lb_target, lb_extract, ArchiveFormat7Zip!) end if |
Example 3
This example extracts two files (test1.txt, test2.txt) and a folder
(test_folder) from the package.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
ExtractorObject lnv_extractor string ls_source, ls_password, ls_extractfiles[], ls_target long ll_return lnv_extractor = create ExtractorObject ls_source = "E:Test.rar" ls_extractfiles[1] = "test1.txt" ls_extractfiles[2] = "test2.txt" //Suppose a folder is specified to be extracted, then all //of the files contained in this folder will be extracted. ls_extractfiles[3] = "test_folder" ls_target = "E:" //Suppose the package requires a password lnv_extractor.Password = ls_password ll_return = lnv_extractor.extract (ls_source, ls_extractfiles, ls_target) |
Example 4
This example extracts test1.txt from the package into a blob data.
You can only extract one file (not a folder or multiple files) into a
blob.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
ExtractorObject lnv_extractor string ls_source, ls_password, ls_extractfile long ll_return blob blb_target lnv_extractor = create ExtractorObject ls_source = "E:Test.rar" ls_extractfile = "test1.txt" //Suppose the package requires a password lnv_extractor.Password = ls_password //Extract one file (cannot be multiple files or a folder) into a blob ll_return = lnv_extractor.extract (ls_source, ls_extractfile, blb_target) |
See also