From: why the lucky stiff Date: 2003-07-18T04:34:30+09:00 Subject: Re: Can I write to a File object from a C extension? On Thursday 17 July 2003 12:39 pm, Tim Hunter wrote: > I have a function written in C that wants to write to a FILE * > returned from fopen. I'd like to use this function to write to a File > object that has been opened for output by File.open(). > > Is this possible? If so, how? Poke around in rubyio.h and you'll find some macros and functions pertinent to this. VALUE rubyFilePtr; OpenFile *openFilePtr; FILE *cFilePtr; rubyFile = rb_file_open( 'filename', 'rw' ); GetOpenFile(rubyFilePtr, openFilePtr); rb_io_check_writable(openFilePtr); cFilePtr = GetWriteFile(openFilePtr); _why