← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/File/HomeDir/Unix.pm
StatementsExecuted 13 statements in 535µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111199µs270µsFile::HomeDir::Unix::::BEGIN@8File::HomeDir::Unix::BEGIN@8
11114µs14µsFile::HomeDir::Unix::::BEGIN@5File::HomeDir::Unix::BEGIN@5
1119µs9µsFile::HomeDir::Unix::::BEGIN@11File::HomeDir::Unix::BEGIN@11
1117µs35µsFile::HomeDir::Unix::::BEGIN@10File::HomeDir::Unix::BEGIN@10
1117µs17µsFile::HomeDir::Unix::::BEGIN@6File::HomeDir::Unix::BEGIN@6
1113µs3µsFile::HomeDir::Unix::::BEGIN@7File::HomeDir::Unix::BEGIN@7
0000s0sFile::HomeDir::Unix::::_my_homeFile::HomeDir::Unix::_my_home
0000s0sFile::HomeDir::Unix::::my_dataFile::HomeDir::Unix::my_data
0000s0sFile::HomeDir::Unix::::my_desktopFile::HomeDir::Unix::my_desktop
0000s0sFile::HomeDir::Unix::::my_documentsFile::HomeDir::Unix::my_documents
0000s0sFile::HomeDir::Unix::::my_homeFile::HomeDir::Unix::my_home
0000s0sFile::HomeDir::Unix::::my_musicFile::HomeDir::Unix::my_music
0000s0sFile::HomeDir::Unix::::my_picturesFile::HomeDir::Unix::my_pictures
0000s0sFile::HomeDir::Unix::::my_videosFile::HomeDir::Unix::my_videos
0000s0sFile::HomeDir::Unix::::users_dataFile::HomeDir::Unix::users_data
0000s0sFile::HomeDir::Unix::::users_desktopFile::HomeDir::Unix::users_desktop
0000s0sFile::HomeDir::Unix::::users_documentsFile::HomeDir::Unix::users_documents
0000s0sFile::HomeDir::Unix::::users_homeFile::HomeDir::Unix::users_home
0000s0sFile::HomeDir::Unix::::users_musicFile::HomeDir::Unix::users_music
0000s0sFile::HomeDir::Unix::::users_picturesFile::HomeDir::Unix::users_pictures
0000s0sFile::HomeDir::Unix::::users_videosFile::HomeDir::Unix::users_videos
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::HomeDir::Unix;
2
3# See POD at the end of the file for documentation
4
5237µs114µs
# spent 14µs within File::HomeDir::Unix::BEGIN@5 which was called: # once (14µs+0s) by File::HomeDir::Darwin::BEGIN@7 at line 5
use 5.00503;
# spent 14µs making 1 call to File::HomeDir::Unix::BEGIN@5
6217µs228µs
# spent 17µs (7+10) within File::HomeDir::Unix::BEGIN@6 which was called: # once (7µs+10µs) by File::HomeDir::Darwin::BEGIN@7 at line 6
use strict;
# spent 17µs making 1 call to File::HomeDir::Unix::BEGIN@6 # spent 10µs making 1 call to strict::import
7215µs13µs
# spent 3µs within File::HomeDir::Unix::BEGIN@7 which was called: # once (3µs+0s) by File::HomeDir::Darwin::BEGIN@7 at line 7
use Carp ();
# spent 3µs making 1 call to File::HomeDir::Unix::BEGIN@7
8284µs1270µs
# spent 270µs (199+71) within File::HomeDir::Unix::BEGIN@8 which was called: # once (199µs+71µs) by File::HomeDir::Darwin::BEGIN@7 at line 8
use File::HomeDir::Driver ();
# spent 270µs making 1 call to File::HomeDir::Unix::BEGIN@8
9
10230µs264µs
# spent 35µs (7+28) within File::HomeDir::Unix::BEGIN@10 which was called: # once (7µs+28µs) by File::HomeDir::Darwin::BEGIN@7 at line 10
use vars qw{$VERSION @ISA};
# spent 35µs making 1 call to File::HomeDir::Unix::BEGIN@10 # spent 28µs making 1 call to vars::import
11
# spent 9µs within File::HomeDir::Unix::BEGIN@11 which was called: # once (9µs+0s) by File::HomeDir::Darwin::BEGIN@7 at line 14
BEGIN {
121300ns $VERSION = '1.00';
1319µs @ISA = 'File::HomeDir::Driver';
141341µs19µs}
# spent 9µs making 1 call to File::HomeDir::Unix::BEGIN@11
15
- -
20#####################################################################
21# Current User Methods
22
23sub my_home {
24 my $class = shift;
25 my $home = $class->_my_home(@_);
26
27 # On Unix in general, a non-existant home means "no home"
28 # For example, "nobody"-like users might use /nonexistant
29 if ( defined $home and ! -d $home ) {
30 $home = undef;
31 }
32
33 return $home;
34}
35
36sub _my_home {
37 my $class = shift;
38 if ( exists $ENV{HOME} and defined $ENV{HOME} ) {
39 return $ENV{HOME};
40 }
41
42 # This is from the original code, but I'm guessing
43 # it means "login directory" and exists on some Unixes.
44 if ( exists $ENV{LOGDIR} and $ENV{LOGDIR} ) {
45 return $ENV{LOGDIR};
46 }
47
48 ### More-desperate methods
49
50 # Light desperation on any (Unixish) platform
51 SCOPE: {
52 my $home = (getpwuid($<))[7];
53 return $home if $home and -d $home;
54 }
55
56 return undef;
57}
58
59# On unix by default, everything is under the same folder
60sub my_desktop {
61 shift->my_home;
62}
63
64sub my_documents {
65 shift->my_home;
66}
67
68sub my_data {
69 shift->my_home;
70}
71
72sub my_music {
73 shift->my_home;
74}
75
76sub my_pictures {
77 shift->my_home;
78}
79
80sub my_videos {
81 shift->my_home;
82}
83
- -
88#####################################################################
89# General User Methods
90
91sub users_home {
92 my ($class, $name) = @_;
93
94 # IF and only if we have getpwuid support, and the
95 # name of the user is our own, shortcut to my_home.
96 # This is needed to handle HOME environment settings.
97 if ( $name eq getpwuid($<) ) {
98 return $class->my_home;
99 }
100
101 SCOPE: {
102 my $home = (getpwnam($name))[7];
103 return $home if $home and -d $home;
104 }
105
106 return undef;
107}
108
109sub users_desktop {
110 shift->users_home(@_);
111}
112
113sub users_documents {
114 shift->users_home(@_);
115}
116
117sub users_data {
118 shift->users_home(@_);
119}
120
121sub users_music {
122 shift->users_home(@_);
123}
124
125sub users_pictures {
126 shift->users_home(@_);
127}
128
129sub users_videos {
130 shift->users_home(@_);
131}
132
13312µs1;
134
135=pod
136
137=head1 NAME
138
139File::HomeDir::Unix - Find your home and other directories on legacy Unix
140
141=head1 SYNOPSIS
142
143 use File::HomeDir;
144
145 # Find directories for the current user
146 $home = File::HomeDir->my_home; # /home/mylogin
147 $desktop = File::HomeDir->my_desktop; # All of these will...
148 $docs = File::HomeDir->my_documents; # ...default to home...
149 $music = File::HomeDir->my_music; # ...directory
150 $pics = File::HomeDir->my_pictures; #
151 $videos = File::HomeDir->my_videos; #
152 $data = File::HomeDir->my_data; #
153
154=head1 DESCRIPTION
155
156This module provides implementations for determining common user
157directories. In normal usage this module will always be
158used via L<File::HomeDir>.
159
160=head1 SUPPORT
161
162See the support section the main L<File::HomeDir> module.
163
164=head1 AUTHORS
165
166Adam Kennedy E<lt>adamk@cpan.orgE<gt>
167
168Sean M. Burke E<lt>sburke@cpan.orgE<gt>
169
170=head1 SEE ALSO
171
172L<File::HomeDir>, L<File::HomeDir::Win32> (legacy)
173
174=head1 COPYRIGHT
175
176Copyright 2005 - 2011 Adam Kennedy.
177
178Some parts copyright 2000 Sean M. Burke.
179
180This program is free software; you can redistribute
181it and/or modify it under the same terms as Perl itself.
182
183The full text of the license can be found in the
184LICENSE file included with this module.
185
186=cut