Hopefully someone knows this… I’ve googled for a while.
When writing a C extension, how does one access the file descriptor
of a File object from the C code?
Thanks!
~Wayne
s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator
Hopefully someone knows this… I’ve googled for a while.
When writing a C extension, how does one access the file descriptor
of a File object from the C code?
Thanks!
~Wayne
s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator
Wayne E. Seguin wrote:
Hopefully someone knows this… I’ve googled for a while.
When writing a C extension, how does one access the file descriptor of a
File object from the C code?
Take a look at this method in io.c:
static VALUE
rb_io_fileno(io)
VALUE io;
{
OpenFile *fptr;
int fd;
GetOpenFile(io, fptr);
fd = fileno(fptr->f);
return INT2FIX(fd);
}
On Sep 11, 2007, at 14:16, Wayne E. Seguin wrote:
Hopefully someone knows this… I’ve googled for a while.
When writing a C extension, how does one access the file descriptor
of a File object from the C code?
Returns an integer representing the numeric file descriptor for
ios.
$stdin.fileno #=> 0
$stdout.fileno #=> 1
(also known as to_i)
Wayne E. Seguin wrote:
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator
Check the GetOpenFile macro in rubyio.h.
On Sep 11, 2007, at 17:26 , Joel VanderWerf wrote:
{
OpenFile *fptr;
int fd;GetOpenFile(io, fptr); fd = fileno(fptr->f); return INT2FIX(fd);
}
Joel,
Awesome, this is exactly what I was looking for!
Thank you!
~Wayne
s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator
On Sep 11, 2007, at 17:30 , Tim H. wrote:
s///g
Wayne E. Seguin
Sr. Systems Architect & Systems AdministratorCheck the GetOpenFile macro in rubyio.h.
Thank you Tim! Most helpful.
~Wayne
s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs