return 0;
}
$!=0; $?=0;
- my @cmd = ($keeporig ? qw(cp) : qw(mv));
- push @cmd, (qw(--), $src, "$dst.tmp");
+ my @cmd = (qw(cp --), $src, "$dst.tmp");
debugcmd '+',@cmd;
if (system @cmd) {
failedcmd_report_cmd undef, @cmd;
$! = -1;
return 0;
}
- if (rename "$dst.tmp", $dst) {
- return 1;
- } else {
- $@ = f_ "finally install file after mv: %S", $!;
+ if (!rename "$dst.tmp", $dst) {
+ $@ = f_ "finally install file after cp: %S", $!;
return 0;
}
+ if (!$keeporig) {
+ if (!unlink $src) {
+ $@ = f_ "delete old file after cp: %S", $!;
+ return 0;
+ }
+ }
+ return 1;
}
sub hashfile ($) {