octave: Temporary Files

 
 14.2.17 Temporary Files
 -----------------------
 
 Sometimes one needs to write data to a file that is only temporary.
 This is most commonly used when an external program launched from within
 Octave needs to access data.  When Octave exits all temporary files will
 be deleted, so this step need not be executed manually.
 
  -- : [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: Seetempname XREFtempname, Seetempdir XREFtempdir,
DONTPRINTYET       SeeP_tmpdir XREFP_tmpdir, Seetmpfile XREFtmpfile, *noteDONTPRINTYET       SeeP_tmpdir XREFP_tmpdir, Seetmpfile XREFtmpfile, See
      fopen XREFfopen.
 
  -- : [FID, MSG] = tmpfile ()
      Return the file ID corresponding to a new temporary file with a
      unique name.
 
      The file is opened in binary read/write ("w+b") mode and will be
      deleted automatically when it is closed or when Octave exits.
 
      If successful, FID is a valid file ID and MSG is an empty string.
      Otherwise, FID is -1 and MSG contains a system-dependent error
      message.
 
      See also: Seetempname XREFtempname, Seemkstemp XREFmkstemp,
      Seetempdir XREFtempdir, SeeP_tmpdir XREFP_tmpdir.
 
  -- : FNAME = tempname ()
  -- : FNAME = tempname (DIR)
  -- : FNAME = tempname (DIR, PREFIX)
      Return a unique temporary filename as a string.
 
      If PREFIX is omitted, a value of "oct-" is used.
 
      If DIR is also omitted, the default directory for temporary files
      (‘P_tmpdir’) is used.  If DIR is provided, it must exist, otherwise
      the default directory for temporary files is used.
 
      Programming Note: Because the named file is not opened by
      ‘tempname’, it is possible, though relatively unlikely, that it
      will not be available by the time your program attempts to open it.
      If this is a concern, see ‘tmpfile’.
 
      See also: Seemkstemp XREFmkstemp, Seetempdir XREFtempdir,
      SeeP_tmpdir XREFP_tmpdir, Seetmpfile XREFtmpfile.
 
  -- : DIR = tempdir ()
      Return the name of the host system’s directory for temporary files.
 
      The directory name is taken first from the environment variable
      ‘TMPDIR’.  If that does not exist the system default returned by
      ‘P_tmpdir’ is used.
 
DONTPRINTYET       See also: SeeP_tmpdir XREFP_tmpdir, *notetempname:
DONTPRINTYET DONTPRINTYET       See also: SeeP_tmpdir XREFP_tmpdir, Seetempname

      XREFtempname, Seemkstemp XREFmkstemp, *notetmpfile:
DONTPRINTYET DONTPRINTYET       See also: SeeP_tmpdir XREFP_tmpdir, Seetempname

      XREFtempname, Seemkstemp XREFmkstemp, Seetmpfile

      XREFtmpfile.
 
  -- : P_tmpdir ()
      Return the name of the host system’s *default* directory for
      temporary files.
 
      Programming Note: The value returned by ‘P_tmpdir’ is always the
      default location.  This value may not agree with that returned from
      ‘tempdir’ if the user has overridden the default with the ‘TMPDIR’
      environment variable.
 
      See also: Seetempdir XREFtempdir, Seetempname XREFtempname,
      Seemkstemp XREFmkstemp, Seetmpfile XREFtmpfile.