--- files.pm 2005-11-17 08:46:53.000000000 +0800 +++ files.pm.new 2005-12-02 21:51:43.000000000 +0800 @@ -40,6 +40,7 @@ @ISA = qw(Exporter); @EXPORT = qw( &filesInDir &filesInDirRecursively + &filesInDirsOnlyRecursively &dirsInDir &getSuffix &isAudio &isPlaylist &isMovie &readFile &readFileWithExpansion @@ -129,7 +130,7 @@ if ( -f $dir . "/" . $entry ) { - push @FOUND, $entry; + push @FOUND, $dir . "/" . $entry; } } @@ -171,6 +172,35 @@ # +# Read all non . files within directories in the given directory recursively. +# +# The returned list will be sorted. +# +sub filesInDirsOnlyRecursively( $ ) +{ + my ($dir) = (@_); + opendir(DIR, $dir) or warn "Cannot open directory : $dir :$!"; + my @entries = readdir( DIR ); + closedir(DIR); + + my @FOUND = (); + + foreach my $entry ( @entries ) + { + # Skip "dotfiles" + next if ( ( $entry =~ /^\.$/ ) or ( $entry =~ /^\.\.$/ ) ); + + if ( -d $dir . "/" . $entry ) + { + push @FOUND, &filesInDirRecursively( $dir . "/" . $entry ); + } + } + + return( sort(@FOUND ) ); +} + + +# # Return all the directories in the given directory # # The returned list will be sorted.