Commit | Line | Data |
663a8675 |
1 | package TempDir; |
2 | use strict; |
3 | use warnings; |
4 | |
5 | use Exporter 'import'; |
6 | our @EXPORT = qw(mk_temp_dir); |
7 | |
8 | use local::lib (); |
9 | use Cwd; |
10 | use File::Temp qw(tempdir); |
11 | |
12 | sub mk_temp_dir |
13 | { |
14 | my $name_template = shift; |
15 | |
16 | my $path = tempdir($name_template, DIR => Cwd::abs_path('t'), CLEANUP => 1); |
17 | local::lib->ensure_dir_structure_for($path); |
18 | # On Win32 the path where the distribution is built usually contains |
19 | # spaces. This is a problem for some parts of the CPAN toolchain, so |
20 | # local::lib uses the GetShortPathName trick do get an alternate |
21 | # representation of the path that doesn't constain spaces. |
22 | return ($^O eq 'MSWin32') |
23 | ? Win32::GetShortPathName($path) |
24 | : $path |
25 | } |
26 | |
27 | 1; |