OpenMS
Loading...
Searching...
No Matches
TempFiles Class Reference

Temporary files that live until the process exits. More...

#include <OpenMS/SYSTEM/TempFiles.h>

Classes

class  Registry_
 Holds the allocated filenames and deletes the files at program exit. More...
 

Static Public Member Functions

static std::string getTemporaryFile (const std::string &alternative_file="")
 Obtain a temporary filename, ensuring automatic deletion upon exit.
 

Static Private Attributes

static Registry_ registry_
 filenames handed out so far, deleted upon program exit
 

Detailed Description

Temporary files that live until the process exits.

Names are allocated below SystemSettings::getTempDirectory() and every file that still exists at exit is removed.

Member Function Documentation

◆ getTemporaryFile()

static std::string getTemporaryFile ( const std::string &  alternative_file = "")
static

Obtain a temporary filename, ensuring automatic deletion upon exit.

The file is not actually created and only deleted at exit if it exists.

However, if 'alternative_file' is given and not empty, no temporary filename is created and 'alternative_file' is returned (and not destroyed upon exit). This is useful if you have an optional output file, which may, or may not be requested, but you need its content regardless, e.g. for intermediate plotting with R. Thus you can just call this function to get a file which can be used and gets automatically destroyed if needed.

Parameters
[in]alternative_fileIf this string is not empty, no action is taken and it is used as return value
Returns
Full path to a temporary file

Member Data Documentation

◆ registry_

Registry_ registry_
staticprivate

filenames handed out so far, deleted upon program exit