Find::File OS/2

Discussion in 'Perl Misc' started by Dave Saville, Apr 15, 2013.

  1. Dave Saville

    Dave Saville Guest

    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.

    --
    Regards
    Dave Saville
    Dave Saville, Apr 15, 2013
    #1
    1. Advertising

  2. Dave Saville

    Dave Saville Guest

    On Mon, 15 Apr 2013 22:54:33 UTC, Ben Morrow <> wrote:

    Hi Ben

    >
    > Quoth "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.

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

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

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

    --
    Regards
    Dave Saville
    Dave Saville, Apr 16, 2013
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Hansen
    Replies:
    6
    Views:
    406
    Peter.....
    Sep 29, 2004
  2. Wybo Dekker
    Replies:
    1
    Views:
    337
    Yukihiro Matsumoto
    Nov 15, 2005
  3. nani
    Replies:
    2
    Views:
    154
    comp.llang.perl.moderated
    Mar 14, 2008
  4. vdvorkin
    Replies:
    0
    Views:
    388
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    794
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page