summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-10-01 14:06:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-10-01 14:06:54 +0000
commit2f31b7e41025b29938a80160a1194ffdd0afb175 (patch)
tree995d54bc9579ff04dd1ced5516a68ca7be6a3d07
parent37560e24e6edbd2cad9cb48ff38a84a198828a71 (diff)
downloaddrakx-backup-do-not-use-2f31b7e41025b29938a80160a1194ffdd0afb175.tar
drakx-backup-do-not-use-2f31b7e41025b29938a80160a1194ffdd0afb175.tar.gz
drakx-backup-do-not-use-2f31b7e41025b29938a80160a1194ffdd0afb175.tar.bz2
drakx-backup-do-not-use-2f31b7e41025b29938a80160a1194ffdd0afb175.tar.xz
drakx-backup-do-not-use-2f31b7e41025b29938a80160a1194ffdd0afb175.zip
with cp_with_progress_() with a cleaner prototype + the ability to pass
options. (nb: option keep_special is not the default)
-rw-r--r--perl-install/install/any.pm20
1 files changed, 15 insertions, 5 deletions
diff --git a/perl-install/install/any.pm b/perl-install/install/any.pm
index 9b9f3cb16..7586932e2 100644
--- a/perl-install/install/any.pm
+++ b/perl-install/install/any.pm
@@ -462,22 +462,32 @@ sub cp_with_progress {
my $current = shift;
my $total = shift;
my $dest = pop @_;
- @_ or return;
- @_ == 1 || -d $dest or die "cp: copying multiple files, but last argument ($dest) is not a directory\n";
+ cp_with_progress_({ keep_special => 1 }, $wait_message, $total, \@_, $dest);
+}
+sub cp_with_progress_ {
+ my ($options, $wait_message, $total, $list, $dest) = @_;
+ @$list or return;
+ @$list == 1 || -d $dest or die "cp: copying multiple files, but last argument ($dest) is not a directory\n";
+
+ -d $dest or $dest = dirname($dest);
+ _cp_with_progress($options, $wait_message, 0, $total, $list, $dest);
+}
+sub _cp_with_progress {
+ my ($options, $wait_message, $current, $total, $list, $dest) = @_;
- foreach my $src (@_) {
+ foreach my $src (@$list) {
my $dest = $dest;
-d $dest and $dest .= '/' . basename($src);
unlink $dest;
- if (-l $src) {
+ if (-l $src && $options->{keep_special}) {
unless (symlink(readlink($src) || die("readlink failed: $!"), $dest)) {
warn "symlink: can't create symlink $dest: $!\n";
}
} elsif (-d $src) {
-d $dest or mkdir $dest, (stat($src))[2] or die "mkdir: can't create directory $dest: $!\n";
- cp_with_progress($wait_message, $current, $total, glob_($src), $dest);
+ _cp_with_progress($options, $wait_message, $current, $total, [ glob_($src) ], $dest);
} else {
open(my $F, $src) or die "can't open $src for reading: $!\n";
open(my $G, ">", $dest) or die "can't cp to file $dest: $!\n";