Mojo struct
TemporaryDirectory
struct TemporaryDirectory
A temporary directory.
Fields
- name (
String
): The name of the temporary directory.
Implemented traits
AnyType
,
UnknownDestructibility
Methods
__init__
__init__(out self, suffix: String = String(""), prefix: String = String("tmp"), dir: Optional[String] = Optional(None), ignore_cleanup_errors: Bool = False)
Create a temporary directory.
Can be used as a context manager. When used as a context manager, the directory is removed when the context manager exits.
Args:
- suffix (
String
): Suffix to use for the directory name. - prefix (
String
): Prefix to use for the directory name. - dir (
Optional[String]
): Directory in which the directory will be created. - ignore_cleanup_errors (
Bool
): Whether to ignore cleanup errors.
__enter__
__enter__(self) -> String
The function to call when entering the context.
Returns:
The temporary directory name.
__exit__
__exit__(self)
Called when exiting the context with no error.
__exit__(self, err: Error) -> Bool
Called when exiting the context with an error.
Args:
- err (
Error
): The error raised inside the context.
Returns:
True if the temporary directory was removed successfully.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!