3 ###############################################################################
5 # Name : differ (with recursion support) #
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 1996-$now by Author #
11 # Compares files in a directory hierarchy to files in another hierarchy. #
12 # Any files with the same name will be compared and files that exist in one #
13 # but not the other are reported. #
15 ###############################################################################
16 # This program is free software; you can redistribute it and/or modify it #
17 # under the terms of the GNU General Public License as published by the Free #
18 # Software Foundation; either version 2 of the License or (at your option) #
19 # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
20 # version of the License. Please send any updates to "fred@gruntose.com". #
21 ###############################################################################
23 require "diff_lib.pl";
24 require "filename_helper.pl";
26 &install_interrupt_catcher;
28 # check that we received at least one parameter.
34 # get the two directories from the command line.
35 local($destination) = $ARGV[0];
38 # use both the locations they provided.
40 $destination = $ARGV[1];
43 # make the names a little more manipulable.
44 $source = &sanitize_name($source);
45 # print "source is now: $source\n";
46 $destination = &sanitize_name($destination);
47 # print "dest is now: $destination\n";
49 # call the routine that does all the work.
50 &recurse_dirs($source, $destination);
54 ############################################################################
56 sub print_instructions
60 This program requires at least one directory name as a parameter. This is
61 the location to use as the target directory. The second parameter, if
62 provided, is the location to use as the source directory. The recursive
63 differ script will traverse the source hierarchy and attempt to compare
64 the contents of the directories in that hierarchy against the destination
65 hierarchy. This will fail where the hierarchies have different directory
66 structures. But where the directories exist in both hierarchies, their
67 contents are compared against each other and documented in the output.
71 ############################################################################
75 local($src, $dest) = @_;
77 if ($src =~ /\/CVS$/) { return; } # skip comparing repositories.
78 #hmmm: why is only CVS spelled out here? what about the others?
81 print "$src is not a directory.\n";
87 # print "recurse_dirs: source is $src and destination is $dest.\n";
89 opendir(SRC_DIR, $src);
90 local(@source_list) = readdir(SRC_DIR);
92 opendir(DEST_DIR, $dest);
93 local(@dest_list) = readdir(DEST_DIR);
96 ## if (&same_file($src, $dest)) {
97 ## # these appear to be the same directory. we shouldn't recurse in.
98 ##print "found same dirs! $src and $dest\n";
101 # now actually call the differ. this is a prefix traveral of the tree.
105 # remember that the destination is actually the first parameter for
106 # diff_dirs, although the source is first for differ...
107 # print "diffing src=$src against dest=$dest\n";
108 &diff_dirs($dest, $src);
110 print "$break_line\n";
111 print "Source directory has \"$src\", but target does not.\n";
114 # iterate through the directory.
116 foreach $name (@source_list) {
117 local($compare_name) = $dest . "/" . $name;
118 # print "name is $name and to compare is $compare_name.\n";
119 local($new_name) = $src . "/" . $name;
120 #hmmm: need an is important dirname check for this.
121 if ( (-d $new_name) && ($name ne ".") && ($name ne "..")
125 && ($name ne "bin-eclipse")
126 && ($name ne "bin.eclipse")
127 && ($name ne "genned-src")
128 && ($name ne "genned-obj")
129 && ($name ne "codegen")
130 && ($name ne "unit-test-reports")
131 && ($name ne "CVS") ) {
132 # print "recursing on: source $name and destination $compare_name.\n";
133 &recurse_dirs($new_name, $compare_name);