diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-03-11 12:20:08 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-03-11 12:20:08 +0000 |
commit | c05ed87c39fd86500be6c4138b038cc44fdfb196 (patch) | |
tree | 604faf75df3452679d2e79b6262cc792c7ac0288 /MDK | |
parent | b2ce946695a8f33e338146adb836c26581b6cc80 (diff) | |
download | perl-MDK-Common-c05ed87c39fd86500be6c4138b038cc44fdfb196.tar perl-MDK-Common-c05ed87c39fd86500be6c4138b038cc44fdfb196.tar.gz perl-MDK-Common-c05ed87c39fd86500be6c4138b038cc44fdfb196.tar.bz2 perl-MDK-Common-c05ed87c39fd86500be6c4138b038cc44fdfb196.tar.xz perl-MDK-Common-c05ed87c39fd86500be6c4138b038cc44fdfb196.zip |
cp_af() now handles devices (mknod)
Diffstat (limited to 'MDK')
-rw-r--r-- | MDK/Common/File.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm index c596ad5..4573fc4 100644 --- a/MDK/Common/File.pm +++ b/MDK/Common/File.pm @@ -161,7 +161,7 @@ sub rm_rf { sub cp_with_option { my $option = shift @_; - my $keep_symlinks = $option =~ /a/; + my $keep_special = $option =~ /a/; my $dest = pop @_; @@ -177,10 +177,14 @@ sub cp_with_option { if (-d $src) { -d $dest or mkdir $dest, (stat($src))[2] or die "mkdir: can't create directory $dest: $!\n"; cp_af(glob_($src), $dest); - } elsif (-l $src && $keep_symlinks) { + } elsif (-l $src && $keep_special) { unless (symlink(readlink($src) || die("readlink failed: $!"), $dest)) { warn "symlink: can't create symlink $dest: $!\n"; } + } elsif ((-b $src || -c $src) && $keep_special) { + my @stat = stat($src); + require MDK::Common::System; + MDK::Common::System::syscall_('mknod', $dest, $stat[2], $stat[6]) or die "mknod failed (dev $_): $!"; } else { local *F; open F, $src or die "can't open $src for reading: $!\n"; local *G; open G, "> $dest"; |