OpenTemporaryFile - Maple Help

FileTools[Binary]

 OpenTemporaryFile
 open a temporary file for binary operations

 Calling Sequence OpenTemporaryFile(prefix)

Parameters

 prefix - (optional) string prefix for the temporary file's name suffix - (optional) string suffix for the temporary file's name

Description

 • The OpenTemporaryFile() function creates a temporary binary file and opens it for writing. It returns a string giving the name of the file, which can be used as a file handle in other file I/O operations. The filename will be of the form $\mathrm{MapleXXXXXX}$, where each $X$ is replaced with a random character.
 • If the optional prefix is provided, then the generated file name will be of the form $\mathrm{prefixXXXXXX}$.
 • If both a prefix and suffix are provided, then the generated file name will be of the form $\mathrm{prefixXXXXXXsuffix}$. A prefix must be provided if a suffix is to be specified.
 • The current implementation of OpenTemporaryFile is not secure. Between generating the unique filename and creating the file, another process may be able to create a file with the same name. By doing so, the other process can read information from or write information into the file.
 • If no temporary file can be created, an exception is raised.

Examples

 > $\mathrm{fn1}≔\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{OpenTemporaryFile}\right]\left(\right)$
 ${\mathrm{fn1}}{≔}{"MapleEHCMzu0P"}$ (1)
 > $\mathrm{fn2}≔\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{OpenTemporaryFile}\right]\left("/tmp/MyTmp"\right)$
 ${\mathrm{fn2}}{≔}{"/tmp/MyTmp6d7EFrw8"}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Close}\right]\left(\mathrm{fn1}\right)$
 > $\mathrm{FileTools}\left[\mathrm{Binary}\right]\left[\mathrm{Close}\right]\left(\mathrm{fn2}\right)$
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left(\mathrm{fn1}\right)$
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left(\mathrm{fn2}\right)$