New file. Incorporates VMS-specific items into MakeMaker.
[p5sagit/p5-mst-13.2.git] / lib / find.pl
index b853d12..40e613e 100644 (file)
@@ -26,6 +26,8 @@
 #          $dev < 0 &&
 #          ($prune = 1);
 #      }
+#
+# Set the variable $dont_use_nlink if you're using AFS, since AFS cheats.
 
 sub find {
     chop($cwd = `pwd`);
@@ -37,8 +39,8 @@ sub find {
                ($dir,$_) = ($topdir,'.');
                $name = $topdir;
                &wanted;
-               $topdir =~ s,/$,, ;
-               &finddir($topdir,$topnlink);
+               ($fixtopdir = $topdir) =~ s,/$,, ;
+               &finddir($fixtopdir,$topnlink);
            }
            else {
                warn "Can't cd to $topdir: $!\n";
@@ -48,6 +50,7 @@ sub find {
            unless (($dir,$_) = $topdir =~ m#^(.*/)(.*)$#) {
                ($dir,$_) = ('.', $topdir);
            }
+           $name = $topdir;
            chdir $dir && &wanted;
        }
        chdir $cwd;
@@ -61,11 +64,11 @@ sub finddir {
 
     # Get the list of files in the current directory.
 
-    opendir(DIR,'.') || warn "Can't open $dir: $!\n";
+    opendir(DIR,'.') || (warn "Can't open $dir: $!\n", return);
     local(@filenames) = readdir(DIR);
     closedir(DIR);
 
-    if ($nlink == 2) {        # This dir has no subdirectories.
+    if ($nlink == 2 && !$dont_use_nlink) {  # This dir has no subdirectories.
        for (@filenames) {
            next if $_ eq '.';
            next if $_ eq '..';
@@ -82,7 +85,7 @@ sub finddir {
            $nlink = $prune = 0;
            $name = "$dir/$_";
            &wanted;
-           if ($subcount > 0) {    # Seen all the subdirs?
+           if ($subcount > 0 || $dont_use_nlink) {    # Seen all the subdirs?
 
                # Get link count and check for directoriness.