#!/usr/bin/perl # (c) 2002 Martin Pitt (martin@piware.de) # This software is protected by the terms and conditions of the GNU # General Public License (see http://www.gnu.org/copyleft/gpl.html for # details). use Getopt::Std; # filelist( $d ) # generate a recursive list of files in $d; honors per-directory # configuration files .pibackuprc sub filelist { my $d = shift; $d .= '/' if ( substr( $d, -1 ) ne '/' ); # look for exclude file my @excl; if( -r $d.'.pibackuprc' ) { open( EXCL, $d.'.pibackuprc' ) or die "Error: could not open $d.pibackuprc"; while( ) { chomp; push @excl, glob $d.$_; } close EXCL; } # open and traverse dir local *DIR; opendir( DIR, $d ) or print STDERR "Could not open directory $d\n" && return; FILE: while( defined( $f = readdir DIR ) ) { next if $f eq '.' || $f eq '..'; foreach ( @excl ) { next FILE if $d.$f eq $_; } if( !( -l $d.$f ) && -d _ ) { filelist( $d.$f ); } else { if( !$newer || ( ( lstat _ )[9] >= $newer ) ) { print "$d$f$term"; } } } closedir DIR; } getopts( '0n:' ); if( $opt_n ) { $newer = ( lstat $opt_n )[9]; # mtime } $term = $opt_0 ? "\0" : "\n"; $dir = $ARGV[0] || $ENV{'HOME'} || '/'; foreach (glob $dir) { if (-d $_) { filelist $_; } else { print "$_$term"; } }