testutil: rename parameter names to be less confusing
$target was the source of the link, and $source was the target (destination) of the link. Obviously this was hopelessly confusing, so rename to avoid this.
This commit is contained in:
parent
238346f134
commit
ebfbb6cc13
1 changed files with 16 additions and 16 deletions
|
@ -100,28 +100,28 @@ sub new_compat_Stow {
|
||||||
#===== SUBROUTINE ===========================================================
|
#===== SUBROUTINE ===========================================================
|
||||||
# Name : make_link()
|
# Name : make_link()
|
||||||
# Purpose : safely create a link
|
# Purpose : safely create a link
|
||||||
# Parameters: $target => path to the link
|
# Parameters: $link_src => path to the link
|
||||||
# : $source => where the new link should point
|
# : $link_dest => where the new link should point
|
||||||
# : $invalid => true iff $source refers to non-existent file
|
# : $invalid => true iff $link_dest refers to non-existent file
|
||||||
# Returns : n/a
|
# Returns : n/a
|
||||||
# Throws : fatal error if the link can not be safely created
|
# Throws : fatal error if the link can not be safely created
|
||||||
# Comments : checks for existing nodes
|
# Comments : checks for existing nodes
|
||||||
#============================================================================
|
#============================================================================
|
||||||
sub make_link {
|
sub make_link {
|
||||||
my ($target, $source, $invalid) = @_;
|
my ($link_src, $link_dest, $invalid) = @_;
|
||||||
|
|
||||||
if (-l $target) {
|
if (-l $link_src) {
|
||||||
my $old_source = readlink join('/', parent($target), $source)
|
my $old_source = readlink join('/', parent($link_src), $link_dest)
|
||||||
or croak "$target is already a link but could not read link $target/$source";
|
or croak "$link_src is already a link but could not read link $link_src/$link_dest";
|
||||||
if ($old_source ne $source) {
|
if ($old_source ne $link_dest) {
|
||||||
croak "$target already exists but points elsewhere\n";
|
croak "$link_src already exists but points elsewhere\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
croak "$target already exists and is not a link\n" if -e $target;
|
croak "$link_src already exists and is not a link\n" if -e $link_src;
|
||||||
my $abs_target = File::Spec->rel2abs($target);
|
my $abs_target = File::Spec->rel2abs($link_src);
|
||||||
my $target_container = dirname($abs_target);
|
my $link_src_container = dirname($abs_target);
|
||||||
my $abs_source = File::Spec->rel2abs($source, $target_container);
|
my $abs_source = File::Spec->rel2abs($link_dest, $link_src_container);
|
||||||
#warn "t $target c $target_container as $abs_source";
|
#warn "t $link_src c $link_src_container as $abs_source";
|
||||||
if (-e $abs_source) {
|
if (-e $abs_source) {
|
||||||
croak "Won't make invalid link pointing to existing $abs_target"
|
croak "Won't make invalid link pointing to existing $abs_target"
|
||||||
if $invalid;
|
if $invalid;
|
||||||
|
@ -130,8 +130,8 @@ sub make_link {
|
||||||
croak "Won't make link pointing to non-existent $abs_target"
|
croak "Won't make link pointing to non-existent $abs_target"
|
||||||
unless $invalid;
|
unless $invalid;
|
||||||
}
|
}
|
||||||
symlink $source, $target
|
symlink $link_dest, $link_src
|
||||||
or croak "could not create link $target => $source ($!)\n";
|
or croak "could not create link $link_src => $link_dest ($!)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#===== SUBROUTINE ===========================================================
|
#===== SUBROUTINE ===========================================================
|
||||||
|
|
Loading…
Reference in a new issue