FileTools[Compressed]
Extract
uncompress a file and write it out to a new file
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Extract(sourcefilename, destfilename, opts)
sourcefilename
-
string, or string in string
destfilename
string
opts
options as specified below
overwrite : (optional) truefalse ; overwrite file if it exists on disk
includepath : (optional) truefalse ; include directory structure on extract
Extract is an all-in-one command to open a file, uncompress it, and write the uncompressed data out to a new file.
If sourcefilename is a zip archive and destfilename is a path, then all members of the zip archive will be extracted to the given path. To extract a single file from a zip archive, specify sourcefilename using the syntax "specificmember" in "filename.zip".
If the option overwrite=true is given, then an error will not be raised if the file to be extracted already exists on disk. The default is false.
If the option, includepath=true is given, then the subdirectory structure of the given zip file will be preserved in the extracted files. If this option is set to false, then the subdirectory structure will be discarded during extraction. It is undetermined which file will be written if there are multiple files with the same base name. The default is includepath=true.
Construct a file in zip format and extract from it.
zipfile≔FileTools:-TemporaryFile⁡GZtest-,.zip
zipfile≔/tmp/mpldoc4/GZtest-yYoYxV9R.zip
FileTools:-Compressed:-WriteFile( "first" in zipfile, "one");
3
FileTools:-Compressed:-WriteFile( "second" in zipfile, Array(1..50, 0, datatype=integer[1]) );
50
FileTools:-Compressed:-Contents⁡zipfile
first,second
Add directory structure to the zip file and extract it.
dir≔FileTools:-TemporaryFile⁡ztest-
dir≔/tmp/mpldoc4/ztest-bx70dpPu
FileTools:-MakeDirectory⁡dir
FileTools:-Compressed:-Extract⁡zipfile,dir
FileTools:-ListDirectory⁡dir
second,first
FileTools:-Text:-ReadFile⁡cat⁡dir,/first
one
FileTools:-Binary:-ReadFile⁡cat⁡dir,/second
00000000000000000000000000000000000000000000000000
FileTools:-Remove⁡cat⁡dir,/first
FileTools:-Remove⁡cat⁡dir,/second
FileTools:-Compressed:-Extract( "first" in zipfile, dir );
first
FileTools:-RemoveDirectory⁡dir,forceremove
FileTools:-Remove⁡zipfile
The FileTools:-Compressed:-Extract command was introduced in Maple 18.
The and options were introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
FileTools:-Remove
FileTools[Compressed][ReadFile]
Download Help Document