From a42ea4186273d71f71a670d99b2c29abffb8692e Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Sun, 5 Aug 2007 21:11:12 +0200
Subject: [PATCH] add backup-getfiles (part of old pibackup)

---
 backup-getfiles | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100755 backup-getfiles

diff --git a/backup-getfiles b/backup-getfiles
new file mode 100755
index 0000000..e577e28
--- /dev/null
+++ b/backup-getfiles
@@ -0,0 +1,64 @@
+#!/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( <EXCL> ) {
+	    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] || '/';
+foreach (glob $dir) {
+    if (-d $_) {
+        filelist $_;
+    } else {
+        print "$_$term";
+    }
+}
-- 
2.39.5