in reply to Re^4: how to handle the warnings in a find statement
in thread how to handle the warnings in a find statement

Wow

Im not sure you realize that the "wanted" sub gets passed directories too. i often have a return unless (-f $file); in there.

another thing the wanted sub can do is signal to prune the tree. $File::Find::prune = 1 is a signal to File::Find not to follow a directory. You want to prune junction points.

# this test for directory $stat->{mode} & S_IFDIR ? print "Directory\n" : print "File\n" +; # is the same as this one $stat->{attribs} & FILE_ATTRIBUTE_DIRECTORY ? print "Directory +\n" : print "File\n"; my $isjunction= <.. some code to see if its a junction ..> ; if ($isjunction){ $File::Find::prune = 1 return; }
now you may even be able to contrive a test <.. some code to see if its a junction ..> that does not require "use Win32::LongPath", i dont know what it is now. Otherwise i think you are stuck trying to install that module. , sorry

Replies are listed 'Best First'.
Re^6: how to handle the warnings in a find statement
by huck (Prior) on Dec 20, 2016 at 10:13 UTC
Re^6: how to handle the warnings in a find statement
by Aldebaran (Curate) on Dec 21, 2016 at 05:55 UTC

    https://github.com/rdboisvert/Win32-LongPath is the repository for this module. I'm almost glad for the opportunity to clone this, as using git was part of the exercises for _Intermediate Perl_, as well as using find statements. The readme says to dmake the product:

    What this shows is the exact same litany of errors I got yesterday with cpan. This will mean something to a prognosticator. Let me first trot out the actual command:

    gcc -c  "-I." "-I."     -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields -Wall -W -Wno-comment -s -O2       -DVERSION=\"1.07\"    -DXS_VERSION=\"1.07\" -o xs\LongPath.o  "-IC:\STRAWB~1\perl\lib\CORE"  -DUSE_PPPORT -DWINVER=0x0a00 -D_WIN32_WINNT=0x0a00 xs\LongPath.c

    I know C well enough to see that this seems syntactic, whilst not really knowing more than half of the flags. (You tell me what -DCONSERVATIVE is, and I'll be impressed.) The first errors cite hv.h, which seems to be how perl defines hashes. I believe this is how perl pre-declares C to achieve that data structure:

    The way I read it, gcc fails in the early phases because we've got the warnings/strictness dialed up pretty darn high. So I'm twice a loser with installing this mod, once with cpan, u takzhe dmaking as per README. So those are my woes that I offer undo the gods of perl. I didn't wash out completely, though and cleared one variety of diagnostic by inclusion of:

    return unless (-f $file);

    But I achieved something else with the part of the script that doesn't depend on cpan. I downloaded the module at pi time, and put it in my local::lib for strawberry perl, which was set to "My Documents". Lo and behold, they are showing up only under 'Documents', so the warning that I can't open the directory "My Documents" doesn't correspond to something that went unsearched. I'd still like to handle the event so my script is clear of warnings.

    As a bonus insight, I got to see where the machine model for C stopped. It's close to M = .19 in these data:

    Seek help with LongPath.

      Hi

      The first errors cite hv.h ...

      Its a warning, and its not in the target distribution (longpath) so ignore it :)

      LongPath.xs:80: error: `SYMBOLIC_LINK_FLAG_DIRECTORY' undeclared (first use in this function) xs\\LongPath.xs:

      Thats the show stopper :)

      On my machine that is defined in

      ...mingw32\i686-w64-mingw32\include\winbase.h 2752:#define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1

      So two ways to fix this, edit winbase.h to define this constant, or edit LongPath.xs