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.
Associated functions
Create
pub func Create(
allocator: Allocator,
directory: Path,
prefix: char8[..]
) -> TemporaryDirectoryHandle ! 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: &TemporaryDirectoryHandle) -> Path
The directory's path, for building names inside it.
Returns: the path it was created at
Close
pub func Close(
self: &var TemporaryDirectoryHandle,
allocator: Allocator
) -> ! 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(self: &var TemporaryDirectoryHandle)
Leaves the directory where it is, giving up the name.
Destructor
func ~TemporaryDirectoryHandle(self: &var TemporaryDirectoryHandle)
Removes the directory with the outcome discarded: the safety net, not the contract.