class

Crtemp

Inherits Dir < Iterable < Enumerable < Reference < Object

Constants

VERSION = "0.1.1"

Constructors

new

Creates a new temporary directory.

Arguments are passed directly to File.tempname to generate the directory name. The directory is created with secure permissions (0o700) and is automatically cleaned up when the Crtemp instance is closed or finalized.

Raises:

  • CreationError if the directory cannot be created
  • PermissionError if the parent directory has insecure permissions
Source

Class methods

create

Creates a new temporary directory with Result-based error handling.

Arguments are passed directly to File.tempname to generate the directory name. The directory is created with secure permissions (0o700) and cleanup must be handled manually by calling #close.

Returns:

  • Success with Crtemp instance on successful creation
  • Failure with CreationError or PermissionError on failure
Source

Instance methods

close

Closes and removes the temporary directory and all its contents.

This method is idempotent - calling it multiple times has no effect after the first call.

Source
create_tempfile_result(prefix : String, data : Slice(UInt8) | Nil = nil) : CrtempResult::Result(String, Crtemp::Error)

Result-returning variant of create_tempfile

Source
finalize
Source

Nested types