temporaryFileName

Return arbitrary name of a file that does not exist and is in a directory where access rights allow to write to this file (useful for temporary output of files)

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

fileName = Files.temporaryFileName();

Description

Return arbitrary name of a file that does not exist and is in a directory where access rights allow to write to this file (useful for temporary output of files).

The created temporary file is not automatically deleted when closed, but needs to be explicitly deleted, e.g. by removeFile(fileName).

Warning: The underlying C implementation of ModelicaInternal_temporaryFileName calls the standard C function tmpnam, which has a race condition security problem in the case another process creates a file with the same fileName just after tmpnam generated the full path name.

Example

fileName = Files.temporaryFileName();
   -> fileName is the absolute path name of the temporary file
Streams.print(String(System.getPid()), fileName);
   -> Create the temporary file
      Warning: Possible race condition on file access
Files.removeFile(fileName);
   -> Explicitly delete the temporary file (after use)

Syntax

fileName = temporaryFileName()

Outputs (1)

fileName

Type: String

Description: Full path name of temporary file