1
package File::HomeDir::Unix;
3
# Unix-specific functionality
8
use File::HomeDir::Driver ();
10
use vars qw{$VERSION @ISA};
13
@ISA = 'File::HomeDir::Driver';
20
#####################################################################
21
# Current User Methods
25
my $home = $class->_my_home(@_);
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 ) {
38
if ( exists $ENV{HOME} and defined $ENV{HOME} ) {
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} ) {
48
### More-desperate methods
50
# Light desperation on any (Unixish) platform
52
my $home = (getpwuid($<))[7];
53
return $home if $home and -d $home;
59
# On unix by default, everything is under the same folder
88
#####################################################################
89
# General User Methods
92
my ($class, $name) = @_;
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;
102
my $home = (getpwnam($name))[7];
103
return $home if $home and -d $home;
110
shift->users_home(@_);
113
sub users_documents {
114
shift->users_home(@_);
118
shift->users_home(@_);
122
shift->users_home(@_);
126
shift->users_home(@_);
130
shift->users_home(@_);
139
File::HomeDir::Unix - find your home and other directories, on Unix
143
This module provides implementations for determining common user
144
directories. In normal usage this module will always be
145
used via L<File::HomeDir>.
151
# Find directories for the current user
152
$home = File::HomeDir->my_home; # /home/mylogin
154
$desktop = File::HomeDir->my_desktop; # All of these will...
155
$docs = File::HomeDir->my_documents; # ...default to home...
156
$music = File::HomeDir->my_music; # ...directory at the...
157
$pics = File::HomeDir->my_pictures; # ...moment.
158
$videos = File::HomeDir->my_videos; #
159
$data = File::HomeDir->my_data; #
165
=item * Add support for common unix desktop and data directories when using KDE / Gnome / ...