mkdtemp

Generates a uniquely named temporary directory from template.

The last six characters of template must be XXXXXX and these are replaced with a string that makes the directory name unique. The directory is then created with permissions 0700.

version(Posix)
@trusted
string
mkdtemp
(
in string templateString
)

Return Value

Type: string

The generated directory name.

Examples

import std.algorithm : startsWith;
import std.file : isDir, rmdir;

string tempDir = mkdtemp(".unittest-XXXXXX");

try
{
    assert(isDir(tempDir));
    assert(tempDir.startsWith(".unittest-"));
}
finally
{
    rmdir(tempDir);
}

Meta