X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Ffind.pl;h=40e613e97ee03d2cebe4fdf6a7942bf550fdb55e;hb=684427cc5594ea737f7b3fd0c729171147faf717;hp=b853d12f402584f9632faa4e39f986928c505f0c;hpb=6e21c824d91ef0b4ae60b95b347e344e5bb4d38a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/find.pl b/lib/find.pl index b853d12..40e613e 100644 --- a/lib/find.pl +++ b/lib/find.pl @@ -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.