develooper Front page | perl.perl5.porters | Postings from January 2009

Re: S_IFLNK() Availability on Win32 (and other non-UNIX systems)

Thread Previous | Thread Next
From:
Shlomi Fish
Date:
January 14, 2009 03:19
Subject:
Re: S_IFLNK() Availability on Win32 (and other non-UNIX systems)
Message ID:
200901141303.11537.shlomif@iglu.org.il
On Wednesday 14 January 2009 11:29:03 Rafael Garcia-Suarez wrote:
> 2009/1/14 Shlomi Fish <shlomif@iglu.org.il>:
> > Hi all,
> >
> > I recently uploaded File-Find-Object-0.1.6 to CPAN and got this errror
> > report on MSWin32:
> >
> > http://www.nntp.perl.org/group/perl.cpan.testers/2009/01/msg3039451.html
> >
> > Reading from there, we see the following:
> >
> > {{{
> > Your vendor has not defined Fcntl macro S_IFLNK, used at
> > C:/Perl/lib/Fcntl.pm line 214.
> > # Looks like you planned 3 tests but ran 2.
> > # Looks like your test exited with 255 just after 2.
> >  Dubious, test returned 255 (wstat 65280, 0xff00)
> >  Failed 1/3 subtests
> > }}}
> >
> > This appears multiple times for each test script. The reason it happens
> > is that instead of doing -l / -d / -f / etc. I just do one stat() and
> > then use S_IFLNK() from Fcntl on the mode field of stat (the one with
> > index 2). (To save on system calls).
>
> What's wrong with using _ instead ?

Well, I'm storing the result of stat somewhere, and then checking for whether 
it's a link or not only later. I guess I can also store the return code of -l 
and other things I'm interested in.

>
> > Obviously, it doesn't work on Windows at that report. My questions are:
> >
> > 1. Can I ever expect it to work on Windows?
>
> Dunno. Does Windows 7 implement symbolic links ? I think that's
> unlikely.

I see. I meant on Perl, though.

>
> > 2. Is it fixed on perl-5.8.9 or perl-5.10.0 there?
>
> What do you mean, fixed ? If the OS doesn't support S_IFLNK, you can't
> use it. That's not a bug.

Ah.

>
> > 3. The error report seems to come from ActivePerl (or otherwise a Perl
> > that was built using MS DevStudio). Does S_IFLNK work better on
> > Mingw32-based Perls?
>
> I bet it doesn't, since the libc won't support it anyway. Maybe on
> cygwin there's some kind of compatibility layer ?

OK.

>
> > 4. Why doesn't Perl do the right thing with this macro, like it does
> > using -l.
>
> Because you're using a low level API, comparable to using POSIX.pm for
> example : it tries to be close to your libc, to enable you to do
> difficult things.

I see.

Thanks for your help. I'll amend my code appropriately.

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Understand what Open Source is - http://xrl.us/bjn82

<mauke>    I'm not interested in what you're doing; what are you trying to 
           achieve?
<PerlJam>  mauke: I'm trying to achieve world peace and this regex is
           the last thing standing in my way! ;)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About