Name
SPVM::File::Temp::Dir - Temporary Directories
Description
The File::Temp::Dir class in SPVM has methods to manipulate temporary directories.
Usage
use File::Temp;
my $tmp_dir = File::Temp::Dir->new;
my $tmp_dirname = $tmp_dir->dirname;
# With options
my $tmp_dir = File::Temp::Dir->new({CLEANUP => 0});
Fields
dirname
has dirname : ro string;
A directory path. This is the path of a temporary directoy.
process_id
has process_id : int;
A process ID. This is the process ID of the process that creates a temporary directory.
Class Methods
new
static method new : File::Temp::Dir ($options : object[] = undef);
Creates a new File::Temp::Dir object given the options $options, and returns it.
"process_id" field is set to the current process ID.
new Options
DIR option
DIR
: string = undef
A directory where a temproary directory is created.
TMPDIR option
TMPDIR
: Int = 0
If this value is a true value and the value of "TEMPLATE option" is defined but the value of "DIR option" is not defined, the temporary directory in the system is used as the value of "DIR option".
TEMPLATE option
TEMPLATE
: string = undef
A template. This is the template for the base name of the temporary direcoty and contains multiple X
such as tempXXXXX
.
CLEANUP option
CLEANUP
: Int = 1
If this value is a true value, the program tries to remove the temporary directory when this instance is destroyed.
See "DESTROY" method for details.
DESTROY
method DESTROY : void ();
If the vlaue of "CLEANUP option" is a true value and the current process ID is the same as "process_id" field, removes the temproary directory.
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License