Find::File OS/2

D

Dave Saville

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
issue

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.
 
D

Dave Saville

Hi Ben
Quoth "Dave Saville said:
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
issue

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.

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{^(?:\w:)?[/\\]$};
}
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.

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 Find.pm
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.
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.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top