#!/usr/bin/perl # # Copyright (c) 2002 Steve Slaven, All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # use Getopt::Std; getopts( 'hfamM', \%o ); ( $indir, $outdir ) = @ARGV; die( qq{ recdiff - Author Steve Slaven usage: $0 [-hafmM] INDIR OUTDIR -h This help -m Don't list missing files -M List only missing files -f Form feed after every file diff -a List all files, even if they match Compares files in INDIR to OUTDIR } ) if( ! $outdir || $o{ h } ); $indir =~ s#/$##; $outdir =~ s#/$##; recdiff( $indir ); sub recdiff { my $dir = shift; my( $this, $fullpath, $otherpath ); local *DIR; opendir( DIR, $dir ) || die( "Couldn't open: $dir: $!" ); while( $this = readdir( DIR ) ) { if( ( $this ne "." ) && ( $this ne ".." ) ) { $fullpath = "$dir/$this"; if( -d $fullpath ) { recdiff( $fullpath ); }else { $otherpath = $fullpath; $otherpath =~ s/^$indir//; $otherpath = "$outdir$otherpath"; $tout = ''; $output = ""; $tout .= "!" x 70 . "\n"; $tout .= "$fullpath ** $otherpath " . "*" x 20 . "\n"; $tout .= "!" x 70 . "\n"; if( -f $otherpath ) { $output = `diff -c $fullpath $otherpath` unless $o{ M }; }else { $output = "$otherpath DOES NOT EXIST\n" unless $o{ m }; } if( $output || $o{ a } ) { print $tout, $output; print "\f" if $o{ f }; } } } } closedir( DIR ); }