TemporaryDirectoryHandle structv0.1.0
pub struct TemporaryDirectoryHandle {
// private fields
}
Move-only, with the same contract as TemporaryFile: Close removes it and reports, destruction removes it
quietly, Keep gives up ownership. Removal is of the directory itself and requires it to be empty — nothing
here deletes a tree, because a temporary directory that silently erased whatever a caller put inside it
would be a worse surprise than a refusal.
Constructors
TemporaryDirectoryHandle
pub func TemporaryDirectoryHandle(
allocator: Allocator,
directory: Path,
prefix: char8[..]
) -> TemporaryDirectoryHandle throws IoError
Creates a new temporary directory in directory, named from prefix and sixteen hex digits of entropy.
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
directory | Path | the directory to create it in |
prefix | char8[..] | the text the generated name starts with |
Returns: the created directory, which is removed when closed unless kept
Methods
AsPath
pub func AsPath(&self) -> Path
The directory's path, for building names inside it.
Returns: the path it was created at
Close
pub func Close(
&var self,
allocator: Allocator
) throws IoError
Removes the directory and reports what the removal said.
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
Returns: success when it was removed
Keep
pub func Keep(&var self)
Leaves the directory where it is, giving up the name.
Destructor
func ~TemporaryDirectoryHandle(&var self)
Removes the directory with the outcome discarded: the safety net, not the contract.