summaryrefslogtreecommitdiffstats
path: root/MDK/Common
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-11-16 10:46:10 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-11-16 10:46:10 +0000
commit9ae80ccaf06c68a90daf6f9f5bad8e621df98f75 (patch)
treedf5c294b52186fec6be6b11ce5b3c0ecb82eba72 /MDK/Common
parent09ee43bbe3fdbbf5811c9eddc97b0bd2ac0d10e6 (diff)
downloadperl-MDK-Common-9ae80ccaf06c68a90daf6f9f5bad8e621df98f75.tar
perl-MDK-Common-9ae80ccaf06c68a90daf6f9f5bad8e621df98f75.tar.gz
perl-MDK-Common-9ae80ccaf06c68a90daf6f9f5bad8e621df98f75.tar.bz2
perl-MDK-Common-9ae80ccaf06c68a90daf6f9f5bad8e621df98f75.tar.xz
perl-MDK-Common-9ae80ccaf06c68a90daf6f9f5bad8e621df98f75.zip
MDK::Common::File : add all_files_rec()
Diffstat (limited to 'MDK/Common')
-rw-r--r--MDK/Common/File.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm
index 26923a4..86fb98b 100644
--- a/MDK/Common/File.pm
+++ b/MDK/Common/File.pm
@@ -82,6 +82,10 @@ ensure the file exists, set the modification time to current time
returns all the file in directory (except "." and "..")
+=item all_files_rec(DIRNAME)
+
+returns all the files in directory and the sub-directories (except "." and "..")
+
=item glob_(STRING)
simple version of C<glob>: doesn't handle wildcards in directory (eg:
@@ -117,7 +121,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_f 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 all_files_rec glob_ substInFile expand_symlinks openFileMaybeCompressed catMaybeCompressed);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' }
@@ -220,6 +224,12 @@ sub all {
@l;
}
+sub all_files_rec {
+ my ($d) = @_;
+
+ map { $_, -d $_ ? all_files_rec($_) : () } map { "$d/$_" } all($d);
+}
+
sub glob_ {
my ($d, $f) = $_[0] =~ /\*/ ? (dirname($_[0]), basename($_[0])) : ($_[0], '*');