File Coverage

blib/lib/File/HomeDir/MacOS9.pm
Criterion Covered Total %
statement 22 49 44.9
branch 0 10 0.0
condition 0 12 0.0
subroutine 9 12 75.0
pod 0 3 0.0
total 31 86 36.0


line stmt bran cond sub pod time code
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     1   1086 use 5.008003;
  1         4  
8 1     1   6 use strict;
  1         2  
  1         22  
9 1     1   5 use warnings;
  1         3  
  1         25  
10 1     1   6 use Carp ();
  1         10  
  1         22  
11 1     1   6 use File::HomeDir::Driver ();
  1         2  
  1         30  
12              
13 1     1   6 use vars qw{$VERSION};
  1         2  
  1         42  
14 1     1   6 use base "File::HomeDir::Driver";
  1         2  
  1         125  
15              
16             BEGIN
17             {
18 1     1   415 $VERSION = '1.004';
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             local $@;
27 1     1   172 eval "use prefork 'Mac::Files'";
  0            
  0            
28             }
29              
30             #####################################################################
31             # Current User Methods
32              
33             sub my_home
34             {
35 0     0 0   my $class = shift;
36              
37             # Try for $ENV{HOME} if we have it
38 0 0         if (defined $ENV{HOME})
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 $@;
  0            
50 0           eval {
51 0           my $home = $class->my_desktop;
52 0 0 0       return $home if $home and -d $home;
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__'} = '';
  0            
61 0           my $home = (getpwuid($<))[7];
62 0 0 0       return $home if $home and -d $home;
63             }
64              
65 0           Carp::croak("Could not locate current user's home directory");
66             }
67              
68             sub my_desktop
69             {
70 0     0 0   my $class = shift;
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 0 0       return $home if $home and -d $home;
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     0 0   my ($class, $name) = @_;
87              
88             SCOPE:
89             {
90             # On some platforms getpwnam dies if called at all
91 0           local $SIG{'__DIE__'} = '';
  0            
92 0           my $home = (getpwnam($name))[7];
93 0 0 0       return $home if defined $home and -d $home;
94             }
95              
96 0           Carp::croak("Failed to find home directory for user '$name'");
97             }
98              
99             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.
120              
121             This module is no longer actively maintained, and is included only for
122             extreme back-compatibility.
123              
124             Only the C and C methods are supported.
125              
126             =head1 SUPPORT
127              
128             See the support section the main L module.
129              
130             =head1 AUTHORS
131              
132             Adam Kennedy Eadamk@cpan.orgE
133              
134             Sean M. Burke Esburke@cpan.orgE
135              
136             =head1 SEE ALSO
137              
138             L
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