Mojo struct
TemporaryDirectory
A temporary directory.
Fieldsβ
- βname (
String
): The name of the temporary directory.
Implemented traitsβ
AnyType
Methodsβ
__init__
β
__init__(inout self: Self, suffix: String = "", prefix: String = "tmp", dir: Optional[String] = #kgen.none, ignore_cleanup_errors: Bool = 0)
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: Self) -> String
The function to call when entering the context.
Returns:
The temporary directory name.
__exit__
β
__exit__(self: Self)
Called when exiting the context with no error.
__exit__(self: 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!
π What went wrong?