Open - Maple Help

FileTools[Compressed]

 Open
 open a compressed file for reading or writing

 Calling Sequence Open(filename, options)

Parameters

 filename - string, or string in string options - (optional) argument(s) of the form option=value where option is one of mode, append, format, or gzipopts

Options

 • mode : READ or WRITE
 • append : true or false (default); whether to append to an existing file
 • format : zip or gzip ; specify compression format
 • gzipopts : additional compression options to pass to zlib see FileTools[Compressed].

Description

 • The Open command opens a file to be read or written in gzip or zip format. It returns an integer file descriptor that can be passed to most of the commands in the subpackage FileTools[Compressed].
 • If filename is the name of an existing file, the file is opened for reading unless the append option is passed or the option mode is set to WRITE.  If mode=WRITE is given, filename will be overwritten unless the option append is also given.
 • If filename is not an existing file, then it will be opened for writing.
 • The format will be implicitly determined by the filename -- if the suffix is ".zip", ".ZIP" or if filename is of the form "subfile" in "zipfile", then the system will assume the file is in zip format.  Otherwise it will be opened as if it were in gzip format.  The format=gzip or format=zip option can be used to force the recognition of a specified format.

Examples

 > $\mathrm{file}≔\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)\right)$
 ${\mathrm{file}}{≔}{"/tmp/mpldoc7/GZtest-yYoYxV9R"}$ (1)
 > $\mathrm{fd}≔\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Open}\right]\left(\mathrm{file}\right)$
 ${\mathrm{fd}}{≔}{8654096}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Close}\right]\left(\mathrm{fd}\right)$
 ${0}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Open}\right]\left(\mathrm{file}\right)$
 ${8654096}$ (4)
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Open}\right]\left(\mathrm{file}\right)$
 > $\mathrm{FileTools}\left[\mathrm{Compressed}\right]\left[\mathrm{Close}\right]\left(\mathrm{file}\right)$
 ${0}$ (5)

Compatibility

 • The FileTools[Compressed][Open] command was introduced in Maple 16.