in reply to Re: Testing for existance of subdirectories
in thread Testing for existance of subdirectories

Hurrah!!! have found a solution: (Using a combination of both my attempts) This works with almost no file access at all:
foreach my $file (readdir(CURRENT)) { next if (($file eq ".") || ($file eq "..")); my $checkDir="$dir\\$file"; Win32::File::GetAttributes($checkDir, my $attrib); if ($attrib == 16) { return 1; } }
Not quite sure what I'm doing with that $attrib, but hey it works!! Thanks for your help guys (Needed to think in a diferent direction :)
                    ("`-''-/").___..--''"`-._
                     `6_ 6  )   `-.  (     ).`-.__.`)
                     (_Y_.)'  ._   )  `._ `. ``-..-'
                   _..`--'_..-_/  /--'_..' ,'
                 (il),-''  (li),'  ((!.-'

Replies are listed 'Best First'.
Re: Re: Re: Testing for existance of subdirectories
by mugwumpjism (Hermit) on Aug 19, 2001 at 14:56 UTC

    I would change that test to:

    if ($attrib & 16) { return 1 }

    What you're doing is testing bit 4 of the file attributes, which is probably the "directory" bit. But if this was a read-only, hidden, etc directory, that $attrib would be something else, like 17.

    If that doesn't make sense, here's a hint; ask if this isn't too clear:

    You want to test this bit v 16 = 00010000b 17 = 00010001b ^
      THANK YOU!!! (You read my mind!) I just scanned my D:\ which has lots of dir's with the system bit set, and it wasn't scanning properly the depth properly. (It's working perfectly now :) (Scanned c:\windows testing every sub for subs, in 4secs)
                          ("`-''-/").___..--''"`-._
                           `6_ 6  )   `-.  (     ).`-.__.`)
                           (_Y_.)'  ._   )  `._ `. ``-..-'
                         _..`--'_..-_/  /--'_..' ,'
                       (il),-''  (li),'  ((!.-'