HomeDir/MacOS9.pm

filter: Statementstmt 49.0% 26 / 53 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 3 totaltotal 35.7% 35 / 98 SCAR 36.3
CC
10
Cov
35%
my_home
42.0
my_desktop
12.0
users_home
12.0
CRAP 37.9
« HomeDir/Darwin.pm ↑ Summary HomeDir/Unix.pm »
1 package File::HomeDir::MacOS9;
2  
3 # Half-assed implementation for the legacy Mac OS9 operating system.
4 # Provided mainly to provide legacy compatibility. May be removed at
5 # a later date.
6  
7 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::HomeDir::Driver ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use vars qw{$VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use base "File::HomeDir::Driver";
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 BEGIN
17 {
18 1 ▶ $VERSION = '1.004';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 }
20  
21 # Load early if in a forking environment and we have
22 # prefork, or at run-time if not.
23 SCOPE:
24 {
25 ## no critic qw(RequireInitializationForLocalVars, RequireCheckingReturnValueOfEval)
26 1 local $@;
27 1 ▶ eval "use prefork 'Mac::Files'";
Subroutine BEGIN: called CC=1 SCAR=1.2
28 }
29  
30 #####################################################################
31 # Current User Methods
32  
33 sub my_home
34 {
35 0 ▶ my $class = shift;
Subroutine my_home: not called CC=6 SCAR=37.4
Pod undocumented
36  
37 # Try for $ENV{HOME} if we have it
38 0 ▶ if (defined $ENV{HOME})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"HOME"}) 0 0 0
39 {
40 0 return $ENV{HOME};
41 }
42  
43 ### DESPERATION SETS IN
44  
45 # We could use the desktop
46 SCOPE:
47 {
48 ## no critic qw(RequireInitializationForLocalVars, RequireCheckingReturnValueOfEval)
49 0 local $@;
50 0 eval {
51 0 my $home = $class->my_desktop;
52 0 ▶ return $home if $home and -d $home;
Branch: 1 branch
BranchTrueFalseTotal
if $home and -d $home 0 0 0
Condition0%0/3
$home and -d $home
!ll&&!rl&&r
000
MC/DC0%0/2
$home and -d $home
$home -d $home
Truth table0%0/3
A and B
A= $homeB= -d $home
ABresult
0X0
100
111
53 };
54 }
55  
56 # Desperation on any platform
57 SCOPE:
58 {
59 # On some platforms getpwuid dies if called at all
60 0 local $SIG{'__DIE__'} = '';
61 0 my $home = (getpwuid($<))[7];
62 0 ▶ return $home if $home and -d $home;
Branch: 1 branch
BranchTrueFalseTotal
if $home and -d $home 0 0 0
Condition0%0/3
$home and -d $home
!ll&&!rl&&r
000
MC/DC0%0/2
$home and -d $home
$home -d $home
Truth table0%0/3
A and B
A= $homeB= -d $home
ABresult
0X0
100
111
63 }
64  
65 0 Carp::croak("Could not locate current user's home directory");
66 }
67  
68 sub my_desktop
69 {
70 0 ▶ my $class = shift;
Subroutine my_desktop: not called CC=3 SCAR=24.8
Pod undocumented
71  
72 # Find the desktop via Mac::Files
73 0 local $SIG{'__DIE__'} = '';
74 0 require Mac::Files;
75 0 my $home = Mac::Files::FindFolder(Mac::Files::kOnSystemDisk(), Mac::Files::kDesktopFolderType(),);
76 0 ▶ return $home if $home and -d $home;
Branch: 1 branch
BranchTrueFalseTotal
if $home and -d $home 0 0 0
Condition0%0/3
$home and -d $home
!ll&&!rl&&r
000
MC/DC0%0/2
$home and -d $home
$home -d $home
Truth table0%0/3
A and B
A= $homeB= -d $home
ABresult
0X0
100
111
77  
78 0 Carp::croak("Could not locate current user's desktop");
79 }
80  
81 #####################################################################
82 # General User Methods
83  
84 sub users_home
85 {
86 0 ▶ my ($class, $name) = @_;
Subroutine users_home: not called CC=3 SCAR=24.8
Pod undocumented
87  
88 SCOPE:
89 {
90 # On some platforms getpwnam dies if called at all
91 0 local $SIG{'__DIE__'} = '';
92 0 my $home = (getpwnam($name))[7];
93 0 ▶ return $home if defined $home and -d $home;
Branch: 1 branch
BranchTrueFalseTotal
if defined $home and -d $home 0 0 0
Condition0%0/3
defined $home and -d $home
!ll&&!rl&&r
000
MC/DC0%0/2
defined $home and -d $home
defined $home -d $home
Truth table0%0/3
A and B
A= defined $homeB= -d $home
ABresult
0X0
100
111
94 }
95  
96 0 Carp::croak("Failed to find home directory for user '$name'");
97 }
98  
99 1 1;
100  
101 =pod
102  
103 =head1 NAME
104  
105 File::HomeDir::MacOS9 - Find your home and other directories on legacy Macintosh systems
106  
107 =head1 SYNOPSIS
108  
109 use File::HomeDir;
110
111 # Find directories for the current user
112 $home = File::HomeDir->my_home;
113 $desktop = File::HomeDir->my_desktop;
114  
115 =head1 DESCRIPTION
116  
117 This module provides implementations for determining common user
118 directories on legacy Mac hosts. In normal usage this module will always be
119 used via L<File::HomeDir>.
120  
121 This module is no longer actively maintained, and is included only for
122 extreme back-compatibility.
123  
124 Only the C<my_home> and C<my_desktop> methods are supported.
125  
126 =head1 SUPPORT
127  
128 See the support section the main L<File::HomeDir> module.
129  
130 =head1 AUTHORS
131  
132 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
133  
134 Sean M. Burke E<lt>sburke@cpan.orgE<gt>
135  
136 =head1 SEE ALSO
137  
138 L<File::HomeDir>
139  
140 =head1 COPYRIGHT
141  
142 Copyright 2005 - 2011 Adam Kennedy.
143  
144 Some parts copyright 2000 Sean M. Burke.
145  
146 This program is free software; you can redistribute
147 it and/or modify it under the same terms as Perl itself.
148  
149 The full text of the license can be found in the
150 LICENSE file included with this module.
151  
152 =cut
« HomeDir/Darwin.pm ↑ Summary HomeDir/Unix.pm »