Change 12510 by jhi@alpha on 2001/10/19 19:52:17
Subject: Re: find2perl and File::Find on cdrom filesystems (with Tel's patch
applied to perl-current)
From: David Dyck <[EMAIL PROTECTED]>
Date: Fri, 19 Oct 2001 13:36:09 -0700 (PDT)
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/lib/File/Find.pm#53 edit
Differences ...
==== //depot/perl/lib/File/Find.pm#53 (text) ====
Index: perl/lib/File/Find.pm
--- perl/lib/File/Find.pm.~1~ Fri Oct 19 14:00:05 2001
+++ perl/lib/File/Find.pm Fri Oct 19 14:00:05 2001
@@ -2,7 +2,7 @@
use 5.006;
use strict;
use warnings;
-our $VERSION = '1.02';
+our $VERSION = '1.03';
require Exporter;
require Cwd;
@@ -180,9 +180,6 @@
filehandle that caches the information from the preceding
stat(), lstat(), or filetest.
-Set the variable C<$File::Find::dont_use_nlink> if you're using AFS,
-since AFS cheats.
-
Here's another interesting wanted function. It will find all symbolic
links that don't resolve:
@@ -195,6 +192,23 @@
=head1 CAVEAT
+=over 2
+
+=item $dont_use_nlink
+
+You can set the variable C<$File::Find::dont_use_nlink> to 1, if you want to
+force File::Find to always stat directories. This was used for systems
+that do not have the correct C<nlink> count for directories. Examples are
+ISO-9660 (CD-R), AFS, and operating systems like OS/2, DOS and a couple of
+others.
+
+Since now File::Find should now detect such things on-the-fly and switch it
+self to using stat, this will probably not a problem to you.
+
+If you do set $dont_use_nlink to 1, you will notice slow-downs.
+
+=item symlinks
+
Be aware that the option to follow symbolic links can be dangerous.
Depending on the structure of the directory tree (including symbolic
links to directories) you might traverse a given (physical) directory
@@ -203,6 +217,8 @@
might cause very unpleasant surprises, since you delete or change files
in an unknown directory.
+=back
+
=head1 NOTES
=over 4
@@ -643,6 +659,7 @@
my $dir_pref;
my $dir_rel = $File::Find::current_dir;
my $tainted = 0;
+ my $no_nlink;
if ($Is_MacOS) {
$dir_pref= ($p_dir =~ /:$/) ? $p_dir : "$p_dir:"; # preface
@@ -736,7 +753,13 @@
@filenames = &$pre_process(@filenames) if $pre_process;
push @Stack,[$CdLvl,$dir_name,"",-2] if $post_process;
- if ($nlink == 2 && !$avoid_nlink) {
+ # default: use whatever was specifid
+ # (if $nlink >= 2, and $avoid_nlink == 0, this will switch back)
+ $no_nlink = $avoid_nlink;
+ # if dir has wrong nlink count, force switch to slower stat method
+ $no_nlink = 1 if ($nlink < 2);
+
+ if ($nlink == 2 && !$no_nlink) {
# This dir has no subdirectories.
for my $FN (@filenames) {
next if $FN =~ $File::Find::skip_pattern;
@@ -753,7 +776,7 @@
for my $FN (@filenames) {
next if $FN =~ $File::Find::skip_pattern;
- if ($subcount > 0 || $avoid_nlink) {
+ if ($subcount > 0 || $no_nlink) {
# Seen all the subdirs?
# check for directoriness.
# stat is faster for a file in the current directory
End of Patch.