1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 21:01:16 +02:00

Use $XDG_RUNTIME_DIR for temporary files

This commit is contained in:
Eelco Dolstra 2014-08-13 23:12:57 +02:00
parent fde819f2e2
commit 3bea429ae8
8 changed files with 16 additions and 23 deletions

View file

@ -1,7 +1,9 @@
package Nix::Utils;
use File::Temp qw(tempdir);
our @ISA = qw(Exporter);
our @EXPORT = qw(checkURL uniq writeFile readFile);
our @EXPORT = qw(checkURL uniq writeFile readFile mkTempDir);
$urlRE = "(?: [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*]+ )";
@ -36,3 +38,9 @@ sub readFile {
close TMP or die;
return $s;
}
sub mkTempDir {
my ($name) = @_;
return tempdir("$name.XXXXXX", CLEANUP => 1, DIR => $ENV{"TMPDIR"} // $ENV{"XDG_RUNTIME_DIR"} // "/tmp")
or die "cannot create a temporary directory";
}