Returns the path to a directory for temporary files.
On Windows, this function returns the result of calling the Windows API
function
GetTempPath.
On POSIX platforms, it searches through the following list of directories and
returns the first one which is found to exist:
Struct representing a temporary file. Returned by tempFile.
Path to the file. This is not guaranteed to exist if AutoDelete.yes is specified. For example, on POSIX, the file is deleted as soon as it is created such that, when the last file descriptor to it is closed, the file is deleted. If AutoDelete.no is specified, this path is guaranteed to exist.
Used with tempFile to choose if a temporary file should be deleted automatically when it is closed.
Creates a temporary file. The file is automatically deleted when it is no longer referenced. The temporary file is always opened with both read and write access.
AutoDelete autoDelete | If set to AutoDelete.yes (the default), the file is deleted from the file system after the file handle is closed. Otherwise, the file must be deleted manually. |
string dir | Directory to create the temporary file in. By default, this is tempDir. |
auto f = tempFile.file; assert(f.position == 0); f.write("Hello"); assert(f.position == 5);
auto path = tempFile(AutoDelete.no).path;