Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/File/HomeDir/FreeDesktop.pm |
Statements | Executed 18 statements in 424µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 393µs | 626µs | BEGIN@13 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 18µs | 18µs | BEGIN@8 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 8µs | 10µs | BEGIN@9 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 7µs | 7µs | BEGIN@16 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 6µs | 24µs | BEGIN@15 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 2µs | 2µs | BEGIN@12 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 2µs | 2µs | BEGIN@10 | File::HomeDir::FreeDesktop::
1 | 1 | 1 | 2µs | 2µs | BEGIN@11 | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | _my | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_cache | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_config | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_data | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_desktop | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_documents | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_download | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_music | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_pictures | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_publicshare | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_templates | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | my_videos | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_data | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_desktop | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_documents | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_music | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_pictures | File::HomeDir::FreeDesktop::
0 | 0 | 0 | 0s | 0s | users_videos | File::HomeDir::FreeDesktop::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package File::HomeDir::FreeDesktop; | ||||
2 | |||||
3 | # Specific functionality for unixes running free desktops | ||||
4 | # compatible with (but not using) File-BaseDir-0.03 | ||||
5 | |||||
6 | # See POD at the end of the file for more documentation. | ||||
7 | |||||
8 | 2 | 39µs | 1 | 18µs | # spent 18µs within File::HomeDir::FreeDesktop::BEGIN@8 which was called:
# once (18µs+0s) by File::HomeDir::_DRIVER at line 8 # spent 18µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@8 |
9 | 2 | 17µs | 2 | 13µs | # spent 10µs (8+3) within File::HomeDir::FreeDesktop::BEGIN@9 which was called:
# once (8µs+3µs) by File::HomeDir::_DRIVER at line 9 # spent 10µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@9
# spent 3µs making 1 call to strict::import |
10 | 2 | 13µs | 1 | 2µs | # spent 2µs within File::HomeDir::FreeDesktop::BEGIN@10 which was called:
# once (2µs+0s) by File::HomeDir::_DRIVER at line 10 # spent 2µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@10 |
11 | 2 | 11µs | 1 | 2µs | # spent 2µs within File::HomeDir::FreeDesktop::BEGIN@11 which was called:
# once (2µs+0s) by File::HomeDir::_DRIVER at line 11 # spent 2µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@11 |
12 | 2 | 12µs | 1 | 2µs | # spent 2µs within File::HomeDir::FreeDesktop::BEGIN@12 which was called:
# once (2µs+0s) by File::HomeDir::_DRIVER at line 12 # spent 2µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@12 |
13 | 2 | 62µs | 1 | 626µs | # spent 626µs (393+232) within File::HomeDir::FreeDesktop::BEGIN@13 which was called:
# once (393µs+232µs) by File::HomeDir::_DRIVER at line 13 # spent 626µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@13 |
14 | |||||
15 | 2 | 22µs | 2 | 43µs | # spent 24µs (6+19) within File::HomeDir::FreeDesktop::BEGIN@15 which was called:
# once (6µs+19µs) by File::HomeDir::_DRIVER at line 15 # spent 24µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@15
# spent 19µs making 1 call to vars::import |
16 | # spent 7µs within File::HomeDir::FreeDesktop::BEGIN@16 which was called:
# once (7µs+0s) by File::HomeDir::_DRIVER at line 19 | ||||
17 | 1 | 200ns | $VERSION = '1.00'; | ||
18 | 1 | 6µs | @ISA = 'File::HomeDir::Unix'; | ||
19 | 1 | 237µs | 1 | 7µs | } # spent 7µs making 1 call to File::HomeDir::FreeDesktop::BEGIN@16 |
20 | |||||
21 | # xdg uses $ENV{XDG_CONFIG_HOME}/user-dirs.dirs to know where are the | ||||
22 | # various "my xxx" directories. That is a shell file. The official API | ||||
23 | # is the xdg-user-dir executable. It has no provision for assessing | ||||
24 | # the directories of a user that is different than the one we are | ||||
25 | # running under; the standard substitute user mechanisms are needed to | ||||
26 | # overcome this. | ||||
27 | |||||
28 | 1 | 2µs | 1 | 197µs | my $xdgprog = File::Which::which('xdg-user-dir'); # spent 197µs making 1 call to File::Which::which |
29 | |||||
30 | sub _my { | ||||
31 | # No quoting because input is hard-coded and only comes from this module | ||||
32 | my $thingy = qx($xdgprog $_[1]); | ||||
33 | chomp $thingy; | ||||
34 | return $thingy; | ||||
35 | } | ||||
36 | |||||
37 | # Simple stuff | ||||
38 | sub my_desktop { shift->_my('DESKTOP') } | ||||
39 | sub my_documents { shift->_my('DOCUMENTS') } | ||||
40 | sub my_music { shift->_my('MUSIC') } | ||||
41 | sub my_pictures { shift->_my('PICTURES') } | ||||
42 | sub my_videos { shift->_my('VIDEOS') } | ||||
43 | |||||
44 | sub my_data { | ||||
45 | $ENV{XDG_DATA_HOME} | ||||
46 | or | ||||
47 | File::Spec->catdir( | ||||
48 | shift->my_home, | ||||
49 | qw{ .local share } | ||||
50 | ); | ||||
51 | } | ||||
52 | |||||
53 | sub my_config { | ||||
54 | $ENV{XDG_CONFIG_HOME} | ||||
55 | or | ||||
56 | File::Spec->catdir( | ||||
57 | shift->my_home, | ||||
58 | qw{ .config } | ||||
59 | ); | ||||
60 | } | ||||
61 | |||||
62 | # Custom locations (currently undocumented) | ||||
63 | sub my_download { shift->_my('DOWNLOAD') } | ||||
64 | sub my_publicshare { shift->_my('PUBLICSHARE') } | ||||
65 | sub my_templates { shift->_my('TEMPLATES') } | ||||
66 | |||||
67 | sub my_cache { | ||||
68 | $ENV{XDG_CACHE_HOME} | ||||
69 | || | ||||
70 | File::Spec->catdir(shift->my_home, qw{ .cache }); | ||||
71 | } | ||||
72 | |||||
- - | |||||
77 | ##################################################################### | ||||
78 | # General User Methods | ||||
79 | |||||
80 | sub users_desktop { Carp::croak('The users_desktop method is not available on an XDG based system.'); } | ||||
81 | sub users_documents { Carp::croak('The users_documents method is not available on an XDG based system.'); } | ||||
82 | sub users_music { Carp::croak('The users_music method is not available on an XDG based system.'); } | ||||
83 | sub users_pictures { Carp::croak('The users_pictures method is not available on an XDG based system.'); } | ||||
84 | sub users_videos { Carp::croak('The users_videos method is not available on an XDG based system.'); } | ||||
85 | sub users_data { Carp::croak('The users_data method is not available on an XDG based system.'); } | ||||
86 | |||||
87 | 1 | 2µs | 1; | ||
88 | |||||
89 | =pod | ||||
90 | |||||
91 | =head1 NAME | ||||
92 | |||||
93 | File::HomeDir::FreeDesktop - Find your home and other directories on FreeDesktop.org Unix | ||||
94 | |||||
95 | =head1 DESCRIPTION | ||||
96 | |||||
97 | This module provides implementations for determining common user | ||||
98 | directories. In normal usage this module will always be | ||||
99 | used via L<File::HomeDir>. | ||||
100 | |||||
101 | =head1 SYNOPSIS | ||||
102 | |||||
103 | use File::HomeDir; | ||||
104 | |||||
105 | # Find directories for the current user | ||||
106 | $home = File::HomeDir->my_home; # /home/mylogin | ||||
107 | $desktop = File::HomeDir->my_desktop; | ||||
108 | $docs = File::HomeDir->my_documents; | ||||
109 | $music = File::HomeDir->my_music; | ||||
110 | $pics = File::HomeDir->my_pictures; | ||||
111 | $videos = File::HomeDir->my_videos; | ||||
112 | $data = File::HomeDir->my_data; | ||||
113 | |||||
114 | =head1 AUTHORS | ||||
115 | |||||
116 | Jerome Quelin E<lt>jquellin@cpan.org<gt> | ||||
117 | |||||
118 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
119 | |||||
120 | =head1 SEE ALSO | ||||
121 | |||||
122 | L<File::HomeDir>, L<File::HomeDir::Win32> (legacy) | ||||
123 | |||||
124 | =head1 COPYRIGHT | ||||
125 | |||||
126 | Copyright 2009 - 2011 Jerome Quelin. | ||||
127 | |||||
128 | Some parts copyright 2010 Adam Kennedy. | ||||
129 | |||||
130 | This program is free software; you can redistribute | ||||
131 | it and/or modify it under the same terms as Perl itself. | ||||
132 | |||||
133 | The full text of the license can be found in the | ||||
134 | LICENSE file included with this module. | ||||
135 | |||||
136 | =cut |