| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::HomeDir::Darwin::Cocoa; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
766
|
use 5.008003; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
15
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Cwd (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
7
|
1
|
|
|
1
|
|
3
|
use Carp (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use File::HomeDir::Darwin (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use vars qw{$VERSION}; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
42
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use base "File::HomeDir::Darwin"; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
85
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
1
|
|
|
1
|
|
2
|
$VERSION = '1.003_002'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Load early if in a forking environment and we have |
|
18
|
|
|
|
|
|
|
# prefork, or at run-time if not. |
|
19
|
1
|
|
|
|
|
2
|
local $@; ## no critic (Variables::RequireInitializationForLocalVars) |
|
20
|
1
|
|
|
1
|
|
62
|
eval "use prefork 'Mac::SystemDirectory'"; ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval) |
|
|
1
|
|
|
|
|
492
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
##################################################################### |
|
24
|
|
|
|
|
|
|
# Current User Methods |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
## no critic qw(UnusedPrivateSubroutines) |
|
27
|
|
|
|
|
|
|
sub _guess_determined_home |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
32
|
0
|
|
|
|
|
|
my $home = Mac::SystemDirectory::HomeDirectory(); |
|
33
|
0
|
|
0
|
|
|
|
$home ||= $class->SUPER::_guess_determined_home($@); |
|
34
|
0
|
|
|
|
|
|
return $home; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# from 10.4 |
|
38
|
|
|
|
|
|
|
sub my_desktop |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
43
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSDesktopDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|| $class->SUPER::my_desktop; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# from 10.2 |
|
48
|
|
|
|
|
|
|
sub my_documents |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
53
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSDocumentDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|| $class->SUPER::my_documents; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# from 10.4 |
|
58
|
|
|
|
|
|
|
sub my_data |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
63
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSApplicationSupportDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|| $class->SUPER::my_data; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# from 10.6 |
|
68
|
|
|
|
|
|
|
sub my_music |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
73
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSMusicDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|| $class->SUPER::my_music; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# from 10.6 |
|
78
|
|
|
|
|
|
|
sub my_pictures |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
83
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSPicturesDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|| $class->SUPER::my_pictures; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# from 10.6 |
|
88
|
|
|
|
|
|
|
sub my_videos |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
93
|
0
|
0
|
|
|
|
|
eval { $class->_find_folder(Mac::SystemDirectory::NSMoviesDirectory()) } |
|
|
0
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|| $class->SUPER::my_videos; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _find_folder |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
100
|
0
|
|
|
|
|
|
my $name = shift; |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
require Mac::SystemDirectory; |
|
103
|
0
|
|
|
|
|
|
my $folder = Mac::SystemDirectory::FindDirectory($name); |
|
104
|
0
|
0
|
|
|
|
|
return undef unless defined $folder; |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
unless (-d $folder) |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
|
|
|
|
|
|
# Make sure that symlinks resolve to directories. |
|
109
|
0
|
0
|
|
|
|
|
return undef unless -l $folder; |
|
110
|
0
|
0
|
|
|
|
|
my $dir = readlink $folder or return; |
|
111
|
0
|
0
|
|
|
|
|
return undef unless -d $dir; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
return Cwd::abs_path($folder); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=pod |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
File::HomeDir::Darwin::Cocoa - Find your home and other directories on Darwin (OS X) |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This module provides Darwin-specific implementations for determining |
|
128
|
|
|
|
|
|
|
common user directories using Cocoa API through |
|
129
|
|
|
|
|
|
|
L. In normal usage this module will always be |
|
130
|
|
|
|
|
|
|
used via L. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Theoretically, this should return the same paths as both of the other |
|
133
|
|
|
|
|
|
|
Darwin drivers. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Because this module requires L, if the module |
|
136
|
|
|
|
|
|
|
is not installed, L will fall back to L. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
use File::HomeDir; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# Find directories for the current user |
|
143
|
|
|
|
|
|
|
$home = File::HomeDir->my_home; # /Users/mylogin |
|
144
|
|
|
|
|
|
|
$desktop = File::HomeDir->my_desktop; # /Users/mylogin/Desktop |
|
145
|
|
|
|
|
|
|
$docs = File::HomeDir->my_documents; # /Users/mylogin/Documents |
|
146
|
|
|
|
|
|
|
$music = File::HomeDir->my_music; # /Users/mylogin/Music |
|
147
|
|
|
|
|
|
|
$pics = File::HomeDir->my_pictures; # /Users/mylogin/Pictures |
|
148
|
|
|
|
|
|
|
$videos = File::HomeDir->my_videos; # /Users/mylogin/Movies |
|
149
|
|
|
|
|
|
|
$data = File::HomeDir->my_data; # /Users/mylogin/Library/Application Support |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |