File Coverage

blib/lib/Acme/CPANModules/GettingTempDir.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Acme::CPANModules::GettingTempDir;
2              
3 1     1   368729 use strict;
  1         1  
  1         115  
4              
5             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6             our $DATE = '2023-10-29'; # DATE
7             our $DIST = 'Acme-CPANModules-GettingTempDir'; # DIST
8             our $VERSION = '0.002'; # VERSION
9              
10             our $LIST = {
11             summary => 'List of ways of getting system-wide temporary directory in a portable way',
12             description => <<'_',
13              
14             There's the good ol' which has a `tmpdir` function. On Unix it
15             looks at `TMPDIR` environment variable before falling back to `/tmp`.
16             uses this for its `tempdir` when a template is not specified.
17              
18             Then there's which tries a little harder. On Unix, its
19             `get_tempdir` will look at `TMPDIR`, then also `TEMPDIR`, `TMP`, `TEMP`. If none
20             of those are set, it will return the first existing directory from the list:
21             `/tmp`, `/var/tmp`. If everything fails, will die.
22              
23             File::Util::Tempdir also provides `get_user_tempdir` which returns a
24             user-private temporary directory, which can be useful if you want to create
25             temporary file with predetermined names. It will return temporary directory
26             pointed by `XDG_RUNTIME_DIR` (e.g. `/run/user/1000`) or, if unavailable, will
27             create a subdirectory under the world-writable temporary directory (e.g.
28             `/tmp/1000`).
29              
30             _
31             tags => ['task'],
32             entries => [
33             {
34             module=>'File::Spec',
35             },
36             {
37             module=>'File::Util::Tempdir',
38             },
39             ],
40             };
41              
42             1;
43             # ABSTRACT: List of ways of getting system-wide temporary directory in a portable way
44              
45             __END__