I'm writing a .NET adaptor for a C/C++ library where a method "bar" takes a regular stdio FILE*. Is it possible to build an interface so that managed code user can pass a managed (File)Stream? That is without creating an intermediary buffer and code to pipe the data between. Also does the assumption that bar() reads only make things any better?
// native code
void bar(FILE*);
// interface for managed code
void foo(System::IO::FileStream^ file)
{
FILE* stdio_handle = ???;
bar(stdio_handle);
}