develooper Front page | perl.perl5.porters | Postings from January 2001

RE: [PATCH][ID 20010103.001] File::Find not descending into Joli

Thread Previous
From:
Tels
Date:
January 12, 2001 08:56
Subject:
RE: [PATCH][ID 20010103.001] File::Find not descending into Joli
Message ID:
200101121655.LAA507942@www08.hway.net
-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On 12-Jan-01 Tels tried to scribble about:
> -----BEGIN PGP SIGNED MESSAGE-----
> - --- Find.pm.orig     Tue Nov 14 20:27:57 2000
> +++ Find.pm     Fri Jan 12 17:22:17 2001
[snip]

Actually, here is an even better patch. The previous one switched to
slow-mode upon hitting the first dir without proper stat. This one
preserves the global setting and goes faster when coming out of the
equivalent of /cdrom again. Probably some doc fixes (mentioning joliet/afs)
would be needed as well? Can anyone test this withFS please? I'll try an
OS/2/NFS test on monday.

> The email address contained in the From/Reply of this email is NOT

ARG, I thought I set up a rule to strip this for p5p...sorry.

Cheers,

Tels

- --- /usr/local/lib/perl5/5.6.0/File/Find.pm     Tue Nov 14 20:27:57 2000
+++ Find.pm     Fri Jan 12 17:51:15 2001
@@ -393,7 +393,7 @@
     my ($CdLvl,$Level) = (0,0);
     my @Stack;
     my @filenames;
- -    my ($subcount,$sub_nlink);
+    my ($subcount,$sub_nlink,$do_avoid_nlink);
     my $SE= [];
     my $dir_name= $p_dir;
     my $dir_pref= ( $p_dir eq '/' ? '/' : "$p_dir/" );
@@ -465,7 +465,13 @@
        @filenames = readdir DIR;
        closedir(DIR);
 
- -       if ($nlink == 2 && !$avoid_nlink) {
+       # on Joliet ISO CD-ROMs stat() returns falsely 1 as nlink count
+       # instead subdirs+2, so we work around. Use slow method only for the
+       # problematic cases:
+       $do_avoid_nlink = $avoid_nlink;
+       $do_avoid_nlink = 1 if $nlink < 2;
+
+       if ($nlink == 2 && !$do_avoid_nlink) {
            # This dir has no subdirectories.
            for my $FN (@filenames) {
                next if $FN =~ /^\.{1,2}\z/;
@@ -482,7 +488,7 @@
 
            for my $FN (@filenames) {
                next if $FN =~ /^\.{1,2}\z/;
- -               if ($subcount > 0 || $avoid_nlink) {
+               if ($subcount > 0 || $do_avoid_nlink) {
                    # Seen all the subdirs?
                    # check for directoriness.
                    # stat is faster for a file in the current directory



Tels

- --
 "Why do you go so slowly? Do you think this is some kind of game?"
 http://bloodgate.com/thief/     Thief - The Dark Project
 http://bloodgate.com/aifilter   Rewriting the HTML as we know it.
 http://freedomforlinks.de       Fight for your right to link. 
 PGP key available on http://bloodgate.com/tels.asc or via email.


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1

iQEVAwUBOl82xHcLPEOTuEwVAQGLagf/U1lfRJQlsyppQlXwcovWcRPnVPG6JRHV
ojFDsi1EYBY18r2a3atyrfNYi0q6jJ1DJc67RbMzkrxFc1IucEcC3ZNj1N3VaftO
2RKB6HOlzOPqfawE9o0EVk5AdkAoEjac6yrQ0Q4CDccVenFH1nVJ++mI+5ZOlEw2
5IGh29CM/gCMbzCmMNcWTVRHJ4I8yk/4oz5qh+aqWjgONori1VqIqM1ZTVf5nPIp
B2uuVU/MGZHE2WZfgmHS6s9sqAkUmQIipkM+kxqKivGBWic8DnwCdjZ984YJHH92
arkqaq9GzkcCQV8b/rUpj9wDD+wm+7P7ZAIRrpwHbW6SUb3mSoW1Ng==
=Zfxh
-----END PGP SIGNATURE-----

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About