Skip to main content

Mojo function

mkdtemp

mkdtemp(suffix: String = "", prefix: String = "tmp", dir: Optional[String] = None) -> String

Create a temporary directory.

Caller is responsible for deleting the directory when done with it.

Example:

from std.tempfile import mkdtemp
from import os import rmdir

var temp_dir = mkdtemp()
print(temp_dir)
os.rmdir(temp_dir)

Args:

  • โ€‹suffix (String): Suffix to use for the directory name.
  • โ€‹prefix (String): Prefix to use for the directory name.
  • โ€‹dir (Optional): Directory in which the directory will be created.

Returns:

String: The name of the created directory.

Raises:

If the directory can not be created.

Was this page helpful?