Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor tmpdir using private first-rwx-dir
  • Loading branch information
lizmat committed Feb 14, 2015
1 parent f43f963 commit 159c38b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/core/Distro.pm
Expand Up @@ -27,25 +27,28 @@ class Distro does Systemic {
}
}

method !first-rwx-dir(\paths) {
my $io;
for paths.grep(*.defined) -> $path {
$io := $path.IO(:check);
return $io if $io.d && $io.rwx;
}

# alas, nothing worked, use current dir
".".IO;
}

method tmpdir() {
my $ENV := %*ENV;
my $io;
for $!is-win
self!first-rwx-dir(
self.is-win
?? <<
$ENV<TMPDIR> $ENV<TEMP> $ENV<TMP> SYS:/temp C:/system/temp C:/temp /tmp /
$ENV<TMPDIR> $ENV<TEMP> $ENV<TMP> SYS:/temp C:/system/temp C:/temp /tmp /
>>
!! <<
$ENV<TMPDIR> /tmp
$ENV<TMPDIR> /tmp
>>
-> $path {
if $path.defined {
$io := $path.IO(:check);
return $io if $io.d && $io.rwx;
}
}

# alas, nothing worked, use current dir
".".IO;
);
}
}

Expand Down

0 comments on commit 159c38b

Please sign in to comment.