in reply to F_GETFL and Win32
This will return the open mode for a given Perl filehandle as a number.
#! perl -slw use strict; use Inline C => 'DATA', NAME => 'fmode', CLEAN_AFTER_BUILD => 0; open FILE, $ARGV[0] or die "'$ARGV[0]:$!"; printf "%x\n", fmode( \*FILE ); __DATA__ C:\test>fmode "<junk.dat" 1 C:\test>fmode ">junk.dat" 2 C:\test>fmode ">>junk.dat" 2 C:\test>fmode "+<junk.dat" 80 C:\test>fmode "+>junk.dat" 80 C:\test>fmode "+>>junk.dat" 80 __C__ int fmode( FILE *stream ) { return stream->_flag; }
In theory you could grab the XS code generated by Inline::C and form that into a module (Win32::Fmode?) for distribution--but I've never managed to get that to work. Everytime I've tried, xsubpp bellyaches about being unable to parse stuff:
C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp -typemap C:\Perl\lib\ExtUtils\typemap Fmode.xs > Fmode.xsc && C:\Perl\bin\perl.exe -MExtUtils::Command -e mv Fmode.xsc Fmode.c Error: Cannot parse function definition from 'fmode( FILE *stream ) {' in Fmode.xs, line 12
And since none {{censored}} ....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: F_GETFL and Win32
by syphilis (Archbishop) on Mar 08, 2006 at 22:23 UTC | |
by BrowserUk (Patriarch) on Mar 08, 2006 at 22:58 UTC | |
by syphilis (Archbishop) on Mar 09, 2006 at 01:08 UTC |