FileTools[Compressed] - Maple Programming Help

Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Compressed/Write

FileTools[Compressed]

 Write
 write data to a compressed file

 Calling Sequence Write(file, data)

Parameters

 file - string or integer file descriptor data - string or rtable of hardware datatype numbers

Description

 • The Write command compresses and writes data to a file that has been opened with FileTools[Compressed][Open].

Examples

 > $\mathrm{file}≔\mathrm{FileTools}[\mathrm{TemporaryFilename}]\left(\mathrm{cat}\left(\mathrm{FileTools}[\mathrm{TemporaryDirectory}]\left(\right),\mathrm{kernelopts}\left(\mathrm{dirsep}\right),"GZtest-"\right)\right)$
 ${\mathrm{file}}{≔}{"/mnt/tmpfs/mpldoc_slot3/mpldoc2/GZtest-h9gGbgMG"}$ (1)
 > $\mathrm{fd}≔\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Open}]\left(\mathrm{file}\right)$
 ${\mathrm{fd}}{≔}{15512752}$ (2)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Write}]\left(\mathrm{fd},"String1"\right)$
 ${7}$ (3)
 > $\mathrm{data}≔\mathrm{StringTools}[\mathrm{ToByteArray}]\left("String2"\right)$
 ${\mathrm{data}}{≔}\left[\begin{array}{ccccccc}{83}& {116}& {114}& {105}& {110}& {103}& {50}\end{array}\right]$ (4)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Write}]\left(\mathrm{file},\mathrm{data}\right)$
 ${7}$ (5)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Close}]\left(\mathrm{fd}\right)$
 ${0}$ (6)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{ReadFile}]\left(\mathrm{file},\mathrm{string}\right)$
 ${"String1String2"}$ (7)
 > $\mathrm{FileTools}[\mathrm{Remove}]\left(\mathrm{file}\right)$
 > $\mathrm{zipfile}≔\mathrm{FileTools}[\mathrm{TemporaryFilename}]\left(\mathrm{cat}\left(\mathrm{FileTools}[\mathrm{TemporaryDirectory}]\left(\right),\mathrm{kernelopts}\left(\mathrm{dirsep}\right),"GZtest-"\right),".zip"\right)$
 ${\mathrm{zipfile}}{≔}{"/mnt/tmpfs/mpldoc_slot3/mpldoc2/GZtest-QJvmGwj6.zip"}$ (8)
 > fd := FileTools[Compressed][Open]("dataOne" in zipfile,'mode'=WRITE);
 ${\mathrm{fd}}{≔}{0}$ (9)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Write}]\left(\mathrm{fd},"String1"\right)$
 ${7}$ (10)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Write}]\left(\mathrm{fd},"String2"\right)$
 ${8}$ (11)
 > $\mathrm{FileTools}[\mathrm{Compressed}][\mathrm{Close}]\left(\mathrm{fd}\right)$
 ${0}$ (12)
 ${"String1 String2"}$ (13)
 > $\mathrm{FileTools}[\mathrm{Remove}]\left(\mathrm{zipfile}\right)$

Compatibility

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