FileTools
TemporaryFilename
return a filename that may be used for a temporary file
TemporaryFile
return a filepath that may be used for a temporary file
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
TemporaryFilename(prefix,suffix)
TemporaryFile(prefix,suffix,opt)
prefix
-
(optional) string prefix for the temporary name
suffix
(optional) string suffix for the temporary name
opt
(optional) option of the form directory=s as described below
directory=string or one of bindir, datadir, homedir, mapledir, tempdir, toolboxdir, worksheetdir.
The directory option specifies the directory in which the temporary file should be generated. The default value, tempdir, indicates that the directory returned by FileTools[TemporaryDirectory] should be used.
For the meaning of bindir, datadir, homedir, mapledir, or toolboxdir, see kernelopts. For the meaning of worksheetdir, see interface.
The TemporaryFilename function returns a string that can be used as the name of a temporary file. The returned filename is of the form MapleXXXXXX, where each X is replaced with a random character.
The TemporaryFile function performs a similar task but uses a temporary directory as its default destination.
If the optional prefix is provided, then the generated filename will be of the form prefixXXXXXX.
If both a prefix and suffix are provided, then the generated filename will be of the form prefixXXXXXXsuffix. A prefix must be provided if a suffix is to be specified.
Each of the functions TemporaryFilename and TemporaryFile guarantees that the filename it returns did not exist at the time it was called. However, it is possible that another process may create this filename in between the call to TemporaryFilename or TemporaryFile and the moment when the file is actually opened.
While TemporaryFilename and TemporaryFile do not create the temporary file, they do issue an error if this file could not be created.
with⁡FileTools:
Return a filename that is unique in the current directory.
TemporaryFilename⁡
MaplecAYm9LTV
Return a unique filename with extension .txt, in the temporary directory.
TemporaryFile⁡,.txt
/tmp/frlFTfMC.txt
Return a unique filename with extension .csv, in the home directory of the current user.
TemporaryFile⁡MyTemp,.csv,directory=homedir
/home/maple/MyTempyYxVbxdp.csv
Attempt to create a temporary filename in a non-writable directory.
TemporaryFilename⁡/
Error, permission denied
The FileTools[TemporaryFile] command was introduced in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
See Also
file_types
FileTools[Binary][Close]
FileTools[Binary][OpenTemporaryFile]
FileTools[TemporaryDirectory]
FileTools[Text][Close]
FileTools[Text][OpenTemporaryFile]
IO_errors
Download Help Document