Ryan Bloom wrote:
On Friday 30 November 2001 08:53 am, Stas Bekman wrote:
Ryan Bloom wrote:
On Friday 30 November 2001 01:12 am, Stas Bekman wrote:
I'm implementing a PerlIO::APR layer to transparently work with apr_file_t * from Perl. I must implement Perl_fileno() which returns a file descriptor (int on unix or its alternatives) which can be then fed into fstat(2) on unix or the alt function on other platforms.
Currently APR doesn't expose filedesc struct member, I suppose mostly due to the fact that not all supported platforms use the same form of filedesc. I see that os2 and win are different from netware and unix.
Is it possible to expose something like apr_fileno which will return its appropriate filehandle/fd?
Thanks Jeff and Ryan, I didn't know about this function. I was sure that apr_file_io.h specifies all the file manipulation functions (+apr_file_info.h).
Use apr_os_file_get.
Thanks Jeff and Ryan, I didn't know about this function. I was sure that apr_file_io.h specifies all the file manipulation functions (+apr_file_info.h).
This will work on Unix, but Windows and OS/2 will return to OS specific handle. For those, you will need OS specific code to convert it to a filedes.
so there was no need to have this implemented in APR so far, but APR could benefit from having such a function, right?
Not really, no. The whole point of APR is to use the native functions when
available. To be able to go from APR (portable) to native (unportable) is
important, because not all programs are going to use APR right away. However, to go from APR (portable) to native (unportable) to Posix
(portable, kind of, but really bad on Windows and other platforms) doesn't
make much sense. If you want to be portable, use APR not POSIX. If you
have to use POSIX, then write the code to go from native to POSIX for your
own program, we don't want that in APR, because it is advocating using a bad portablility layer.
I understand. In my case I'm not writing my own program, but a Perl glue for APR file IO, so it should be as portable as APR and work with Perl IO. So it looks that I'm going to find a work-around for Perl, so I won't need filedes in the core unless a user wants it and then I'll try to use apr_os_file_get. I'm already discussing this issue on the perl5porters mailing list.
Heh, both Perl and APR are very portable, but it's not easy to glue the two together on the internal low level, since the portability is not implemented in the same ways.
Thanks Ryan.
_____________________________________________________________________ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://ticketmaster.com http://apacheweek.com http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
