summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MDK/Common/File.pm16
-rw-r--r--perl-MDK-Common.spec2
2 files changed, 15 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) {
diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec
index f62ccff..8b3e2a1 100644
--- a/perl-MDK-Common.spec
+++ b/perl-MDK-Common.spec
@@ -72,6 +72,8 @@ rm -rf $RPM_BUILD_ROOT
# MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common
%changelog
+- MDK::Common::File::cp_f() added
+
* Tue Nov 18 2003 Thierry Vignaud <tvignaud@mandrakesoft.com> 1.1.8-3mdk
- perl_checker --generate-pot: unescape "$" & "@" caracters
- substInFile: if file is a symlink, make sure it stays a symlink