FileTools[Compressed]

 read a regular file and write it out as a compressed file

Parameters

 target_filename - string, string in string, or integer file handle source_filename - string or list of strings

Description

 • ReadWriteFile is an all-in-one command to open a file, read all its data, compress, and write it out to another file.  This is done in small blocks, so the input data does not have to be read into the memory all at once.
 • When target_filename is a zip file, the source_filename can be a directory.  In this case, the entire contents of that directory plus all subdirectories, are added to the zip archive.
 • The in-zip file names are copied to match the on-disk filenames minus the base directory path.
 • Since gzip format files cannot contain multiple sub-files, source_filename must be a single string.

Examples

 > $\mathrm{zipfile}≔\mathrm{FileTools}\left[\mathrm{TemporaryFilename}\right]\left(\mathrm{FileTools}\left[\mathrm{JoinPath}\right]\left(\left[\mathrm{FileTools}\left[\mathrm{TemporaryDirectory}\right]\left(\right),"GZtest-"\right]\right),".zip"\right)$
 ${\mathrm{zipfile}}{≔}{"/tmp/mpldoc10/GZtest-yYoYxV9R.zip"}$ (1)
 > $\mathrm{sourcedir}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{mapledir}\right),"/data/xml/schema"\right)$
 ${\mathrm{sourcedir}}{≔}{"/maple/cbat/active/169462/data/xml/schema"}$ (2)
 > $\mathrm{FileTools}:-\mathrm{Compressed}:-\mathrm{ReadWriteFile}\left(\mathrm{zipfile},\mathrm{sourcedir}\right)$
 > $\mathrm{FileTools}:-\mathrm{Compressed}:-\mathrm{Contents}\left(\mathrm{zipfile}\right)$
 $\left[{"schema/mw/mw.xsd"}{,}{"schema/worksheet/common.xsd"}{,}{"schema/worksheet/containers.xsd"}{,}{"schema/worksheet/options.xsd"}{,}{"schema/worksheet/plots.xsd"}{,}{"schema/worksheet/rtables.xsd"}{,}{"schema/worksheet/spread.xsd"}{,}{"schema/worksheet/styles.xsd"}{,}{"schema/worksheet/text.xsd"}{,}{"schema/worksheet/worksheet.dtd"}{,}{"schema/worksheet/worksheet.xsd"}\right]$ (3)
 > FileTools:-Compressed:-Read("schema/worksheet/worksheet.xsd" in zipfile, string, 250);
 ${" (4)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left(\mathrm{zipfile}\right)$

Compatibility

 • The FileTools[Compressed][ReadWriteFile] command was introduced in Maple 18.