######################################################################
# Path.pm
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

package Path;

use Cwd;
use strict;

######################################################################
# Determine absolute path from relative path and current directory:
# $abspath = Path::absolute($relpath);
######################################################################
sub absolute {
    my $relpath = shift;

    Path::cd(cwd(), $relpath);
}

######################################################################
# Relative change to a new directory:
# $newpath = Path::cd($path, $chdir);
######################################################################
sub cd {
    my($from, $to) = @_;

    my $current = cwd();   # store current directory

                           # change to start directory
    Cwd::chdir($from) || return undef;

                           # relative change of
                           # target directory
    Cwd::chdir($to) || (Cwd::chdir($current), return undef);
    
    my $retval = cwd();    # store target directory

    Cwd::chdir($current);  # reset current
                           # directory
    return $retval;
}

1;

