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)
string
mkdtemp
@trusted
(
in string templateString
)

Return Value

Type: string

The generated directory name.

Examples

1 import std.algorithm : startsWith;
2 import std.file : isDir, rmdir;
3 
4 string tempDir = mkdtemp(".unittest-XXXXXX");
5 
6 try
7 {
8     assert(isDir(tempDir));
9     assert(tempDir.startsWith(".unittest-"));
10 }
11 finally
12 {
13     rmdir(tempDir);
14 }

Meta