.Modelica.Utilities.Files.temporaryFileName

Information

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)

Interface

impure function temporaryFileName
  extends Modelica.Icons.Function;
  output String fileName "Full path name of temporary file";
end temporaryFileName;

Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f