diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-11-28 11:35:10 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-11-28 11:35:10 +0000 |
commit | 0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74 (patch) | |
tree | d7933d57fd6ea44f4dc6876ffe737c0907918361 /MDK | |
parent | b92bea3d9e4d4657bbafd07c1ec1430d3859ae7f (diff) | |
download | perl-MDK-Common-0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74.tar perl-MDK-Common-0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74.tar.gz perl-MDK-Common-0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74.tar.bz2 perl-MDK-Common-0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74.tar.xz perl-MDK-Common-0a03f42eb1d5ec02424d78b63d9fc2bd1f8b2e74.zip |
MDK::Common::File::cp_f() added
Diffstat (limited to 'MDK')
-rw-r--r-- | MDK/Common/File.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm index 95b2b30..607b881 100644 --- a/MDK/Common/File.pm +++ b/MDK/Common/File.pm @@ -58,6 +58,10 @@ creates the directory (make parent directories as needed) remove the files (including sub-directories) +=item cp_f(FILES, DEST) + +just like "cp -f" + =item cp_af(FILES, DEST) just like "cp -af" @@ -113,7 +117,7 @@ L<MDK::Common> use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); @ISA = qw(Exporter); -@EXPORT_OK = qw(dirname basename cat_ cat_or_die cat__ output output_p output_with_perm append_to_file linkf symlinkf renamef mkdir_p rm_rf cp_af touch all glob_ substInFile expand_symlinks openFileMaybeCompressed catMaybeCompressed); +@EXPORT_OK = qw(dirname basename cat_ cat_or_die cat__ output output_p output_with_perm append_to_file linkf symlinkf renamef mkdir_p rm_rf cp_f cp_af touch all glob_ substInFile expand_symlinks openFileMaybeCompressed catMaybeCompressed); %EXPORT_TAGS = (all => [ @EXPORT_OK ]); sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' } @@ -155,7 +159,10 @@ sub rm_rf { 1; } -sub cp_af { +sub cp_with_option { + my $option = shift @_; + my $keep_symlinks = $option =~ /a/; + my $dest = pop @_; @_ or return; @@ -170,7 +177,7 @@ sub cp_af { 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) { + } elsif (-l $src && $keep_symlinks) { unless (symlink((readlink($src) || die "readlink failed: $!"), $dest)) { warn "symlink: can't create symlink $dest: $!\n"; } @@ -184,6 +191,9 @@ sub cp_af { 1; } +sub cp_f { cp_with_option('f', @_) } +sub cp_af { cp_with_option('af', @_) } + sub touch { my ($f) = @_; unless (-e $f) { |