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

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

Thread Next
From:
Shlomi Fish
Date:
January 14, 2009 00:48
Subject:
S_IFLNK() Availability on Win32 (and other non-UNIX systems)
Message ID:
200901141047.37068.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).

Obviously, it doesn't work on Windows at that report. My questions are:

1. Can I ever expect it to work on Windows?

2. Is it fixed on perl-5.8.9 or perl-5.10.0 there?

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?

4. Why doesn't Perl do the right thing with this macro, like it does using -l. 
To quote from the third edition of the Camel Book:

{{{
Initially designed as a glue language for Unix, Perl has long since spread to 
most other operating systems. Because it runs nearly everywhere, Perl is one 
of the most portable programming environments available today. To program C or 
C++ portably, you have to put in all those strange #ifdef markings for 
different operating systems. To program Java portably, you have to understand 
the idiosyncrasies of each new Java implementation. To program a shell script 
portably, you have to remember the syntax for each operating system's version 
of each command and somehow find the common factor that (you hope) works 
everywhere. And to program Visual Basic portably, you just need a more 
flexible definition of the word "portable". :-)
}}}

So this is a step in the wrong direction.

Please let me know if I should create a separate sub-class (or whatever) for 
handling Win32.

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"Star Trek: We, the Living Dead" - http://xrl.us/omqz4

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


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