File-HomeDir
view release on metacpan or search on metacpan
a home directory. So in those cases, return undef
instead of the /nonexistant directory.
0.60_08 2017-01-01
- Problems with Win2k hopefully finally resolved
0.60_07 2006-12-19
- Problems with testing continue to plague the module...
0.60_06 2006-12-15
- Another attempt to fix the getpwuid problem
0.60_05 2006-12-12
- Removed a build-time dependency on getpwuid
0.60_04 2006-11-02
- win32: add support for my_pictures, my_videos
- darwin: add support for my_music, my_pictures, my_videos
- Skip "root" tests on darwin, not supported
- add POD docs with examples for o/s specific implementations
0.60_03 2006-09-20
- Cleaned up the way unimplemented method exceptions are thrown.
- Fleshed out the docs a bit more.
lib/File/HomeDir/MacOS9.pm view on Meta::CPAN
local $@;
eval {
my $home = $class->my_desktop;
return $home if $home and -d $home;
};
}
# Desperation on any platform
SCOPE:
{
# On some platforms getpwuid dies if called at all
local $SIG{'__DIE__'} = '';
my $home = (getpwuid($<))[7];
return $home if $home and -d $home;
}
Carp::croak("Could not locate current user's home directory");
}
sub my_desktop
{
my $class = shift;
lib/File/HomeDir/Unix.pm view on Meta::CPAN
return;
}
sub _guess_determined_home
{
my $class = shift;
# Light desperation on any (Unixish) platform
SCOPE:
{
my $home = (getpwuid($<))[7];
return $home if $home and -d $home;
}
return;
}
sub _guess_home
{
my $class = shift;
my $home = $class->_guess_env_home($@);
lib/File/HomeDir/Unix.pm view on Meta::CPAN
shift->my_home;
}
#####################################################################
# General User Methods
sub users_home
{
my ($class, $name) = @_;
# IF and only if we have getpwuid support, and the
# name of the user is our own, shortcut to my_home.
# This is needed to handle HOME environment settings.
if ($name eq getpwuid($<))
{
return $class->my_home;
}
SCOPE:
{
my $home = (getpwnam($name))[7];
return $home if $home and -d $home;
}
t/02_main.t view on Meta::CPAN
else
{
$HAVEMUSIC = 1;
$HAVEVIDEOS = 0; # If we ever support "maybe" this is a maybe
}
# System is unix-like
# Nobody users on all unix systems generally don't have home directories
}
elsif (getpwuid($<) eq 'nobody')
{
$HAVEHOME = 0;
$HAVEDESKTOP = 0;
$HAVEMUSIC = 0;
$HAVEPICTURES = 0;
$HAVEVIDEOS = 0;
$HAVEOTHERS = 0;
}
elsif ($^O eq 'darwin')
t/02_main.t view on Meta::CPAN
# On platforms other than windows, find root's homedir
SKIP:
{
if ($^O eq 'MSWin32' or $^O eq 'cygwin' or $^O eq 'darwin')
{
skip("Skipping root test on $^O", 1);
}
# Determine root
my $root = getpwuid(0);
unless ($root)
{
skip("Skipping, can't determine root", 1);
}
# Get root's homedir
my $root_home1 = home($root);
ok(!!($root_home1 and is_dir $root_home1), "Found root's home directory");
}
t/20_empty_home.t view on Meta::CPAN
$^W = 1;
$ENV{HOME} = '';
}
use Test::More;
use File::HomeDir;
plan skip_all => "Skipping empty \$ENV{HOME} test on $^O since there is no fallback" if ($^O eq 'MSWin32');
plan(tests => 1);
my $home = (getpwuid($<))[7];
is scalar File::HomeDir->my_home, $home, 'my_home found';
( run in 0.512 second using v1.01-cache-2.11-cpan-8d75d55dd25 )