our @EXPORT = qw(cd compact_path full_path
##############################################################################
# Note this function is not at all robust. Should work on that
my $canon_dir1 = File
::Spec
->canonpath(File
::Spec
->rel2abs($dir1));
my $canon_dir2 = File
::Spec
->canonpath(File
::Spec
->rel2abs($dir2));
return ($canon_dir1 eq $canon_dir2);
##############################################################################
# ACTUALLY A CLASS METHOD
if(not are_dirs_same
($dir, getcwd
)) {
##############################################################################
# Not for public consumption
return unless defined $this->{old
};
cd
(compact_path
($this->{old
}));
##############################################################################
##############################################################################
return $$Full_paths if ref $Full_paths;
##############################################################################
foreach my $key (keys %args) {
if($key eq 'full_paths') {
$Full_paths = $args{$key};
fatal
"Midas::Paths does not recongnize configuration option ".
return ( full_paths
=> opt_full_paths
);
##############################################################################
# Converts to full or relative (to $relto or cwd) path, whichever is shorter.
# If Full_Paths is enabled, then always return full path.
##############################################################################
$relto = getcwd
unless defined $relto;
my $abs = File
::Spec
->rel2abs($path, $relto);
my $rel = File
::Spec
->abs2rel($abs, $relto);
my $compact = ((length $rel) < (length $abs)) ?
$rel : $abs;
$compact = '.' if length($compact) == 0;
return opt_full_paths
() ?
$abs : $compact;
##############################################################################
$relto = getcwd
unless defined $relto;
my $abs = File
::Spec
->rel2abs($path, $relto);
##############################################################################
$dir = File
::Spec
->rel2abs($dir);
chdir $dir or fatal
"Can't cd to $dir: $!\n", M_DIR
;
##############################################################################
# Get filename. $file argument is a full path or a path relative to
# build_dir. Second argument defines build_dir. If no second
# argument, assume build_dir is cwd. If it's a string, assume the
# string is build_dir. If it's a reference, assume it's a
# Midas::State object. Return value is the compact path to the file.
##############################################################################
my $arg = shift; # either build_dir or state object or undef for build=cwd
# Do the require at this late date so as to not mess up exports
# (this is a circular include).
$build_dir = $state->get_build_dir('-abs');
$expanded_file = File
::Spec
->rel2abs($file, $build_dir);
return compact_path
$expanded_file;
##############################################################################
##############################################################################