Close
Close window
TemporaryFile - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

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

TemporaryFilename(prefix,suffix)

TemporaryFile(prefix,suffix,opt)

Parameters

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

Options

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 .

Description

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.

Examples

>

withFileTools:

Return a filename that is unique in the current directory.

>

TemporaryFilename

MaplecAYm9LTV

(1)

Return a unique filename with extension .txt, in the temporary directory.

>

TemporaryFile,.txt

/tmp/frlFTfMC.txt

(2)

Return a unique filename with extension .csv, in the home directory of the current user.

>

TemporaryFileMyTemp,.csv,directory=homedir

/home/maple/MyTempyYxVbxdp.csv

(3)

Attempt to create a temporary filename in a non-writable directory.

>

TemporaryFilename/

Compatibility

The FileTools[TemporaryFile] command was introduced in Maple 2017.

For more information on Maple 2017 changes, see Updates in Maple 2017 .


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /