Find::File OS/2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a script that needs to obtain a list of files. The script takes
an argument as to where to start looking in the directory tree. So I  

find(\&wanted, $start);

If $start equals drive and directory such as t:/foo then all is fine.  
But if I need to start in the root of a drive such as t: then find  
throws an error:

Can't stat t:: No such file or directory

Note the double colon.

t: & t:/ both give the same error.

Just giving t gives a slightly different error with t: rather than t::

t:/. works as does t:. - but messes all subsequent returned fully  
qualified paths as in t:/./foo.  

Any ideas gratefully received. What I am doing for now is check if it  
is only a drive and change start to 'x:.' then inside wanted() I strip
that off and replace with what was supplied. Messy, there must be a  
better way.

Dave Saville

Re: Find::File OS/2

Quoted text here. Click to load it

Well, the first thing to say is that File::Find appears to strip a
trailing slash off the path passed to it, unless that path is "/". The
relevant bit of File::Find is (I think; the code's rather hard to
follow) line 521, in sub _find_opt:

        if ($Is_Win32) {
            $top_item =~ s|[/\]\z||
              unless $top_item =~ m;
        else {
            $top_item =~ s|/\z|| unless $top_item eq '/';

so my first guess would be that this is an OS/2 portability bug, and
OS/2 should be included in the first branch of the if. It might be worth
changing your copy to see if that works, and checking all the other uses
of $Is_Win32 in that file as well. If this fixes the problem, report a
bug to p5p.

Quoted text here. Click to load it

Out of interest, does OS/2 have the same behaviour as Win32, where "t:"
is not the same path as "t:/"? On Win32 the system maintains a current
directory per drive plus a current drive, and "t:" refers to the current
directory on drive t rather than its root.


Re: Find::File OS/2

Hi Ben

Quoted text here. Click to load it

Still on 5.8.2 because I cannot upgrade due to module install not  
working on OS/2 and there is no mention of Win32 anywhere in  
1.05. There are similar bits of code for MacOS and I tried tweaking  
the bit that seemed to match but that just made things worse. My work  
around works so untill we fix the install, that will do. We may be  
back on the install problem soon BTW.
 > > Just giving t gives a slightly different error with t: rather  
than t::
Quoted text here. Click to load it

Yes it's the same as Win. Has caught me out several times in the past.

Dave Saville

Site Timeline