JoinPaths is weird after all

This commit is contained in:
adam 2006-01-02 01:18:25 +00:00 committed by Adam Spiers
parent 921041f2a8
commit d2afbae421

25
Stow.pm
View file

@ -116,16 +116,23 @@ sub RelativePath {
&JoinPaths(@b); &JoinPaths(@b);
} }
# Concatenates the paths given as arguments, removing double slashes. # Concatenates the paths given as arguments, removing double and
# trailing slashes. Is subtlely different from File::Spec::join
# in other aspects, e.g. args ('', '/foo') yields 'foo' not '/foo'.
sub JoinPaths { sub JoinPaths {
# The code that was previously here from 1.3.3 was strangely complex my(@paths, @parts);
# for no obvious reason. I (Adam) wrote a test suite and found this my ($x, $y);
# drop-in replacement to behave identically. my($result) = '';
# my $result = join '/', @_;
# $result =~ s!//!/!g; $result = '/' if ($_[0] =~ /^\//);
# return $result; foreach $x (@_) {
# So does this, but is also portable. @parts = split(/\/+/, $x);
return File::Spec->join(@_); foreach $y (@parts) {
push(@paths, $y) if ($y ne "");
}
}
$result .= join('/', @paths);
return $result;
} }
# This removes stow-controlled symlinks from $targetdir for the # This removes stow-controlled symlinks from $targetdir for the