Navigation

Operators and Keywords

Function List:

C++ API

: [fid, name, msg] = mkstemp ("template")
: [fid, name, msg] = mkstemp ("template", delete)

Return the file descriptor fid corresponding to a new temporary file with a unique name created from template.

The last six characters of template must be "XXXXXX" and these are replaced with a string that makes the filename unique. The file is then created with mode read/write and permissions that are system dependent (on GNU/Linux systems, the permissions will be 0600 for versions of glibc 2.0.7 and later). The file is opened in binary mode and with the O_EXCL flag.

If the optional argument delete is supplied and is true, the file will be deleted automatically when Octave exits.

If successful, fid is a valid file ID, name is the name of the file, and msg is an empty string. Otherwise, fid is -1, name is empty, and msg contains a system-dependent error message.

See also: tempname, tempdir, P_tmpdir, tmpfile, fopen.

Package: octave