line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::HomeDir::Test; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
85014
|
use 5.008003; |
|
1
|
|
|
|
|
17
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
8
|
use Carp (); |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
7
|
use File::Spec (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
871
|
use File::Temp (); |
|
1
|
|
|
|
|
26175
|
|
|
1
|
|
|
|
|
31
|
|
9
|
1
|
|
|
1
|
|
480
|
use File::HomeDir::Driver (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use vars qw{$VERSION %DIR $ENABLED}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
64
|
|
12
|
1
|
|
|
1
|
|
8
|
use base "File::HomeDir::Driver"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
190
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN |
15
|
|
|
|
|
|
|
{ |
16
|
1
|
|
|
1
|
|
5
|
$VERSION = '1.004'; |
17
|
1
|
|
|
|
|
3
|
%DIR = (); |
18
|
1
|
|
|
|
|
618
|
$ENABLED = 0; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Special magic use in test scripts |
22
|
|
|
|
|
|
|
sub import |
23
|
|
|
|
|
|
|
{ |
24
|
1
|
|
|
1
|
|
11
|
my $class = shift; |
25
|
1
|
50
|
|
|
|
5
|
Carp::croak "Attempted to initialise File::HomeDir::Test trice" if %DIR; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Fill the test directories |
28
|
1
|
|
|
|
|
5
|
my $BASE = File::Temp::tempdir(CLEANUP => 1); |
29
|
1
|
|
|
|
|
1352
|
%DIR = map { $_ => File::Spec->catdir($BASE, $_) } qw{ |
|
7
|
|
|
|
|
49
|
|
30
|
|
|
|
|
|
|
my_home |
31
|
|
|
|
|
|
|
my_desktop |
32
|
|
|
|
|
|
|
my_documents |
33
|
|
|
|
|
|
|
my_data |
34
|
|
|
|
|
|
|
my_music |
35
|
|
|
|
|
|
|
my_pictures |
36
|
|
|
|
|
|
|
my_videos |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Hijack HOME to the home directory |
40
|
1
|
|
|
|
|
11
|
$ENV{HOME} = $DIR{my_home}; ## no critic qw(LocalizedPunctuationVars) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Make File::HomeDir load us instead of the native driver |
43
|
1
|
|
|
|
|
4
|
$File::HomeDir::IMPLEMENTED_BY = # Prevent a warning |
44
|
|
|
|
|
|
|
$File::HomeDir::IMPLEMENTED_BY = 'File::HomeDir::Test'; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Ready to go |
47
|
1
|
|
|
|
|
38
|
$ENABLED = 1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
##################################################################### |
51
|
|
|
|
|
|
|
# Current User Methods |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub my_home |
54
|
|
|
|
|
|
|
{ |
55
|
1
|
50
|
|
1
|
0
|
110
|
mkdir($DIR{my_home}, oct(755)) unless -d $DIR{my_home}; |
56
|
1
|
|
|
|
|
9
|
return $DIR{my_home}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub my_desktop |
60
|
|
|
|
|
|
|
{ |
61
|
1
|
50
|
|
1
|
0
|
70
|
mkdir($DIR{my_desktop}, oct(755)) unless -d $DIR{my_desktop}; |
62
|
1
|
|
|
|
|
9
|
return $DIR{my_desktop}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub my_documents |
66
|
|
|
|
|
|
|
{ |
67
|
1
|
50
|
|
1
|
0
|
68
|
mkdir($DIR{my_documents}, oct(755)) unless -f $DIR{my_documents}; |
68
|
1
|
|
|
|
|
9
|
return $DIR{my_documents}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub my_data |
72
|
|
|
|
|
|
|
{ |
73
|
1
|
50
|
|
1
|
0
|
72
|
mkdir($DIR{my_data}, oct(755)) unless -d $DIR{my_data}; |
74
|
1
|
|
|
|
|
9
|
return $DIR{my_data}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub my_music |
78
|
|
|
|
|
|
|
{ |
79
|
1
|
50
|
|
1
|
0
|
70
|
mkdir($DIR{my_music}, oct(755)) unless -d $DIR{my_music}; |
80
|
1
|
|
|
|
|
9
|
return $DIR{my_music}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub my_pictures |
84
|
|
|
|
|
|
|
{ |
85
|
1
|
50
|
|
1
|
0
|
69
|
mkdir($DIR{my_pictures}, oct(755)) unless -d $DIR{my_pictures}; |
86
|
1
|
|
|
|
|
9
|
return $DIR{my_pictures}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub my_videos |
90
|
|
|
|
|
|
|
{ |
91
|
1
|
50
|
|
1
|
0
|
68
|
mkdir($DIR{my_videos}, oct(755)) unless -d $DIR{my_videos}; |
92
|
1
|
|
|
|
|
9
|
return $DIR{my_videos}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub users_home |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
0
|
|
return undef; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |