Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/HomeDir/Darwin/Cocoa.pm |
Statements | Executed 666 statements in 4.60ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 570µs | 1.50ms | BEGIN@7 | File::HomeDir::Darwin::Cocoa::
55 | 5 | 1 | 517µs | 3.77ms | _find_folder | File::HomeDir::Darwin::Cocoa::
55 | 1 | 1 | 214µs | 214µs | CORE:ftdir (opcode) | File::HomeDir::Darwin::Cocoa::
11 | 1 | 1 | 50µs | 2.29ms | my_desktop | File::HomeDir::Darwin::Cocoa::
11 | 1 | 1 | 48µs | 449µs | my_music | File::HomeDir::Darwin::Cocoa::
11 | 1 | 1 | 48µs | 417µs | my_pictures | File::HomeDir::Darwin::Cocoa::
11 | 1 | 1 | 46µs | 407µs | my_videos | File::HomeDir::Darwin::Cocoa::
22 | 1 | 1 | 46µs | 46µs | my_home | File::HomeDir::Darwin::Cocoa::
11 | 1 | 1 | 45µs | 448µs | my_data | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 39µs | 83µs | BEGIN@10 | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 16µs | 16µs | BEGIN@3 | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 8µs | 20µs | BEGIN@4 | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 8µs | 36µs | BEGIN@9 | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 4µs | 4µs | BEGIN@5 | File::HomeDir::Darwin::Cocoa::
1 | 1 | 1 | 3µs | 3µs | BEGIN@6 | File::HomeDir::Darwin::Cocoa::
0 | 0 | 0 | 0s | 0s | my_documents | File::HomeDir::Darwin::Cocoa::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package File::HomeDir::Darwin::Cocoa; | ||||
2 | |||||
3 | 2 | 40µs | 1 | 16µs | # spent 16µs within File::HomeDir::Darwin::Cocoa::BEGIN@3 which was called:
# once (16µs+0s) by File::HomeDir::_DRIVER at line 3 # spent 16µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@3 |
4 | 2 | 20µs | 2 | 33µs | # spent 20µs (8+13) within File::HomeDir::Darwin::Cocoa::BEGIN@4 which was called:
# once (8µs+13µs) by File::HomeDir::_DRIVER at line 4 # spent 20µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@4
# spent 13µs making 1 call to strict::import |
5 | 2 | 21µs | 1 | 4µs | # spent 4µs within File::HomeDir::Darwin::Cocoa::BEGIN@5 which was called:
# once (4µs+0s) by File::HomeDir::_DRIVER at line 5 # spent 4µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@5 |
6 | 2 | 15µs | 1 | 3µs | # spent 3µs within File::HomeDir::Darwin::Cocoa::BEGIN@6 which was called:
# once (3µs+0s) by File::HomeDir::_DRIVER at line 6 # spent 3µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@6 |
7 | 2 | 80µs | 1 | 1.50ms | # spent 1.50ms (570µs+930µs) within File::HomeDir::Darwin::Cocoa::BEGIN@7 which was called:
# once (570µs+930µs) by File::HomeDir::_DRIVER at line 7 # spent 1.50ms making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@7 |
8 | |||||
9 | 2 | 36µs | 2 | 64µs | # spent 36µs (8+28) within File::HomeDir::Darwin::Cocoa::BEGIN@9 which was called:
# once (8µs+28µs) by File::HomeDir::_DRIVER at line 9 # spent 36µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@9
# spent 28µs making 1 call to vars::import |
10 | # spent 83µs (39+44) within File::HomeDir::Darwin::Cocoa::BEGIN@10 which was called:
# once (39µs+44µs) by File::HomeDir::_DRIVER at line 18 | ||||
11 | 1 | 400ns | $VERSION = '1.00'; | ||
12 | 1 | 5µs | @ISA = 'File::HomeDir::Darwin'; | ||
13 | |||||
14 | # Load early if in a forking environment and we have | ||||
15 | # prefork, or at run-time if not. | ||||
16 | 1 | 100ns | local $@; | ||
17 | 1 | 22µs | eval "use prefork 'Mac::SystemDirectory'"; # spent 55µs executing statements in string eval # includes 44µs spent executing 1 call to 1 sub defined therein. | ||
18 | 1 | 284µs | 1 | 83µs | } # spent 83µs making 1 call to File::HomeDir::Darwin::Cocoa::BEGIN@10 |
19 | |||||
- - | |||||
24 | ##################################################################### | ||||
25 | # Current User Methods | ||||
26 | |||||
27 | # spent 46µs within File::HomeDir::Darwin::Cocoa::my_home which was called 22 times, avg 2µs/call:
# 22 times (46µs+0s) by File::HomeDir::my_home at line 93 of File/HomeDir.pm, avg 2µs/call | ||||
28 | 22 | 5µs | my $class = shift; | ||
29 | |||||
30 | # A lot of unix people and unix-derived tools rely on | ||||
31 | # the ability to overload HOME. We will support it too | ||||
32 | # so that they can replace raw HOME calls with File::HomeDir. | ||||
33 | 22 | 67µs | if ( exists $ENV{HOME} and defined $ENV{HOME} ) { | ||
34 | return $ENV{HOME}; | ||||
35 | } | ||||
36 | |||||
37 | require Mac::SystemDirectory; | ||||
38 | return Mac::SystemDirectory::HomeDirectory(); | ||||
39 | } | ||||
40 | |||||
41 | # from 10.4 | ||||
42 | # spent 2.29ms (50µs+2.24) within File::HomeDir::Darwin::Cocoa::my_desktop which was called 11 times, avg 208µs/call:
# 11 times (50µs+2.24ms) by File::HomeDir::my_desktop at line 97 of File/HomeDir.pm, avg 208µs/call | ||||
43 | 11 | 3µs | my $class = shift; | ||
44 | |||||
45 | 11 | 3µs | require Mac::SystemDirectory; | ||
46 | 11 | 22µs | eval { | ||
47 | 11 | 16µs | 11 | 2.24ms | $class->_find_folder(Mac::SystemDirectory::NSDesktopDirectory()) # spent 2.24ms making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 203µs/call |
48 | } | ||||
49 | || | ||||
50 | $class->SUPER::my_desktop; | ||||
51 | } | ||||
52 | |||||
53 | # from 10.2 | ||||
54 | sub my_documents { | ||||
55 | my $class = shift; | ||||
56 | |||||
57 | require Mac::SystemDirectory; | ||||
58 | eval { | ||||
59 | $class->_find_folder(Mac::SystemDirectory::NSDocumentDirectory()) | ||||
60 | } | ||||
61 | || | ||||
62 | $class->SUPER::my_documents; | ||||
63 | } | ||||
64 | |||||
65 | # from 10.4 | ||||
66 | # spent 448µs (45+403) within File::HomeDir::Darwin::Cocoa::my_data which was called 11 times, avg 41µs/call:
# 11 times (45µs+403µs) by File::HomeDir::my_data at line 127 of File/HomeDir.pm, avg 41µs/call | ||||
67 | 11 | 3µs | my $class = shift; | ||
68 | |||||
69 | 11 | 3µs | require Mac::SystemDirectory; | ||
70 | 11 | 21µs | eval { | ||
71 | 11 | 12µs | 11 | 403µs | $class->_find_folder(Mac::SystemDirectory::NSApplicationSupportDirectory()) # spent 403µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 37µs/call |
72 | } | ||||
73 | || | ||||
74 | $class->SUPER::my_data; | ||||
75 | } | ||||
76 | |||||
77 | # from 10.6 | ||||
78 | # spent 449µs (48+400) within File::HomeDir::Darwin::Cocoa::my_music which was called 11 times, avg 41µs/call:
# 11 times (48µs+400µs) by File::HomeDir::my_music at line 109 of File/HomeDir.pm, avg 41µs/call | ||||
79 | 11 | 4µs | my $class = shift; | ||
80 | |||||
81 | 11 | 4µs | require Mac::SystemDirectory; | ||
82 | 11 | 21µs | eval { | ||
83 | 11 | 13µs | 11 | 400µs | $class->_find_folder(Mac::SystemDirectory::NSMusicDirectory()) # spent 400µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 36µs/call |
84 | } | ||||
85 | || | ||||
86 | $class->SUPER::my_music; | ||||
87 | } | ||||
88 | |||||
89 | # from 10.6 | ||||
90 | # spent 417µs (48+369) within File::HomeDir::Darwin::Cocoa::my_pictures which was called 11 times, avg 38µs/call:
# 11 times (48µs+369µs) by File::HomeDir::my_pictures at line 115 of File/HomeDir.pm, avg 38µs/call | ||||
91 | 11 | 4µs | my $class = shift; | ||
92 | |||||
93 | 11 | 3µs | require Mac::SystemDirectory; | ||
94 | 11 | 19µs | eval { | ||
95 | 11 | 13µs | 11 | 369µs | $class->_find_folder(Mac::SystemDirectory::NSPicturesDirectory()) # spent 369µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 34µs/call |
96 | } | ||||
97 | || | ||||
98 | $class->SUPER::my_pictures; | ||||
99 | } | ||||
100 | |||||
101 | # from 10.6 | ||||
102 | # spent 407µs (46+361) within File::HomeDir::Darwin::Cocoa::my_videos which was called 11 times, avg 37µs/call:
# 11 times (46µs+361µs) by File::HomeDir::my_videos at line 121 of File/HomeDir.pm, avg 37µs/call | ||||
103 | 11 | 3µs | my $class = shift; | ||
104 | |||||
105 | 11 | 3µs | require Mac::SystemDirectory; | ||
106 | 11 | 21µs | eval { | ||
107 | 11 | 13µs | 11 | 361µs | $class->_find_folder(Mac::SystemDirectory::NSMoviesDirectory()) # spent 361µs making 11 calls to File::HomeDir::Darwin::Cocoa::_find_folder, avg 33µs/call |
108 | } | ||||
109 | || | ||||
110 | $class->SUPER::my_videos; | ||||
111 | } | ||||
112 | |||||
113 | # spent 3.77ms (517µs+3.25) within File::HomeDir::Darwin::Cocoa::_find_folder which was called 55 times, avg 69µs/call:
# 11 times (124µs+2.11ms) by File::HomeDir::Darwin::Cocoa::my_desktop at line 47, avg 203µs/call
# 11 times (98µs+306µs) by File::HomeDir::Darwin::Cocoa::my_data at line 71, avg 37µs/call
# 11 times (100µs+300µs) by File::HomeDir::Darwin::Cocoa::my_music at line 83, avg 36µs/call
# 11 times (98µs+271µs) by File::HomeDir::Darwin::Cocoa::my_pictures at line 95, avg 34µs/call
# 11 times (98µs+263µs) by File::HomeDir::Darwin::Cocoa::my_videos at line 107, avg 33µs/call | ||||
114 | 55 | 7µs | my $class = shift; | ||
115 | 55 | 6µs | my $name = shift; | ||
116 | |||||
117 | 55 | 8µs | require Mac::SystemDirectory; | ||
118 | 55 | 2.90ms | 55 | 2.72ms | my $folder = Mac::SystemDirectory::FindDirectory($name); # spent 2.72ms making 55 calls to Mac::SystemDirectory::FindDirectory, avg 50µs/call |
119 | 55 | 11µs | return undef unless defined $folder; | ||
120 | |||||
121 | 55 | 311µs | 55 | 214µs | unless ( -d $folder ) { # spent 214µs making 55 calls to File::HomeDir::Darwin::Cocoa::CORE:ftdir, avg 4µs/call |
122 | # Make sure that symlinks resolve to directories. | ||||
123 | return undef unless -l $folder; | ||||
124 | my $dir = readlink $folder or return; | ||||
125 | return undef unless -d $dir; | ||||
126 | } | ||||
127 | |||||
128 | 55 | 554µs | 55 | 313µs | return Cwd::abs_path($folder); # spent 313µs making 55 calls to Cwd::abs_path, avg 6µs/call |
129 | } | ||||
130 | |||||
131 | 1 | 2µs | 1; | ||
132 | |||||
133 | =pod | ||||
134 | |||||
135 | =head1 NAME | ||||
136 | |||||
137 | File::HomeDir::Darwin::Cocoa - Find your home and other directories on Darwin (OS X) | ||||
138 | |||||
139 | =head1 DESCRIPTION | ||||
140 | |||||
141 | This module provides Darwin-specific implementations for determining | ||||
142 | common user directories using Cocoa API through | ||||
143 | L<Mac::SystemDirectory>. In normal usage this module will always be | ||||
144 | used via L<File::HomeDir>. | ||||
145 | |||||
146 | Theoretically, this should return the same paths as both of the other | ||||
147 | Darwin drivers. | ||||
148 | |||||
149 | Because this module requires L<Mac::SystemDirectory>, if the module | ||||
150 | is not installed, L<File::HomeDir> will fall back to L<File::HomeDir::Darwin>. | ||||
151 | |||||
152 | =head1 SYNOPSIS | ||||
153 | |||||
154 | use File::HomeDir; | ||||
155 | |||||
156 | # Find directories for the current user | ||||
157 | $home = File::HomeDir->my_home; # /Users/mylogin | ||||
158 | $desktop = File::HomeDir->my_desktop; # /Users/mylogin/Desktop | ||||
159 | $docs = File::HomeDir->my_documents; # /Users/mylogin/Documents | ||||
160 | $music = File::HomeDir->my_music; # /Users/mylogin/Music | ||||
161 | $pics = File::HomeDir->my_pictures; # /Users/mylogin/Pictures | ||||
162 | $videos = File::HomeDir->my_videos; # /Users/mylogin/Movies | ||||
163 | $data = File::HomeDir->my_data; # /Users/mylogin/Library/Application Support | ||||
164 | |||||
165 | =cut | ||||
# spent 214µs within File::HomeDir::Darwin::Cocoa::CORE:ftdir which was called 55 times, avg 4µs/call:
# 55 times (214µs+0s) by File::HomeDir::Darwin::Cocoa::_find_folder at line 121, avg 4µs/call |