Getting file descriptors from ifstream
Theodore Papadopoulo
Theodore.Papadopoulo@sophia.inria.fr
Wed Nov 9 16:06:00 GMT 2005
On Wed, 2005-11-09 at 14:55 +0100, Paolo Carlini wrote:
> massimiliano cialdi wrote:
>
> >How can I get the file descriptor from an opened ifstream?
> >
> >
> It is not possible without an extension of the standard: we provide one
> in ext/stdio_filebuf.h.
No, this is unfortunately not true (well not totally true). Unless I'm
wrong, it merely allow you to construct a stream from a file descriptor
or a file pointer. Then indeed you can get the file descriptor you
entered at construction time.
It does not help you getting the file descriptor from a stream openened
in a standard way. Richard B. Kreckel posted a solution (partly based on
sdtio_filebuf) to the problem massimiliano asked in this mail-list some
time ago. It is quite ugly but without support from the library, I'm not
sure something better can be found. His solution can be found at:
http://www.ginac.de/~kreckel/fileno/
Maybe it would make sense to integrate this into the ext namespace ???
Theo.
More information about the Libstdc++
mailing list