Devel::PerlySense::Home - A User Home root directory


Devel-PerlySense documentation Contained in the Devel-PerlySense distribution.

Index


Code Index:

NAME

Top

Devel::PerlySense::Home - A User Home root directory

DESCRIPTION

Top

The User Home is the place where User specific settings/cache, etc. are kept.

PROPERTIES

Top

aDirHomeCandidate

List of candidates for User Home root dirs.

Readonly.

dirHome

The User Home root dir, or "" if no home dir could be identified.

Readonly.

dirHomeCache

The User Home cache dir, or "" if no home dir could be identified.

Readonly.

dirHomeLog

The User Home log dir, or "" if no home dir could be identified.

Readonly.

AUTHOR

Top

Johan Lindström, <johanl[ÄT]DarSerMan.com>

BUGS

Top

Please report any bugs or feature requests to bug-devel-perlysense@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Devel-PerlySense documentation Contained in the Devel-PerlySense distribution.




use strict;
use warnings;

package Devel::PerlySense::Home;
our $VERSION = '0.01';



use Spiffy -Base;
use Carp;
use Data::Dumper;
use File::Basename;
use File::Path;
use Path::Class;

use Devel::PerlySense::Util;





sub aDirHomeCandidate {
    return(
        grep { $_ } (
            $ENV{APPDATA},
            $ENV{ALLUSERSPROFILE},
            $ENV{USERPROFILE},
            $ENV{HOME},
            $ENV{TEMP},
            $ENV{TMP},
            "/",
        ),
    );
}





sub dirHome {

    for my $dirHome( $self->aDirHomeCandidate ) {
        my $dir = dir($dirHome, ".PerlySense");
        mkpath([$dir]);
        -d $dir and return $dir;
    }

    return "";
}





sub _dirSubHomeCreate {
    my ($dirSub) = @_;

    my $dirHome = $self->dirHome or return "";
    my $dir = dir($dirHome, $dirSub);
    mkpath([$dir]);
    -d $dir or return "";

    return $dir;    
}
sub dirHomeCache {
    $self->_dirSubHomeCreate("cache");
}





sub dirHomeLog {
    $self->_dirSubHomeCreate("log");
}





1;





__END__