Boost logo

Boost :

From: Gregory Seidman (gseidman_at_[hidden])
Date: 2001-05-27 18:07:45

This is something that I have been thinking about for a while, but haven't
actually brought up since I have been using Sun's CC (it will become
apparent why this is relevant).

With some regularity, I do things with file descriptors. Sometimes it's
sockets, sometimes pipes, sometimes files. I'd like to be able to wrap and
istream/ostream/iostream around a file descriptor. Conveniently,
RogueWave's STL (which comes with Sun's CC) provides a constructor for
{i/o}fstream which takes a file descriptor. Of course, I am then writing
nonstandard C++.

Given that I am already doing something platform-dependent to get the file
descriptors in the first place, I don't consider the nonstandard C++ to be
that big a deal. Still, it would be nice if I could do what I'm trying to
do more portably -- and I can, by subclassing basic_streambuf and
implementing its protected virtual interface to support file descriptors.
It's still platform-dependent, though.

Now, what isn't platform-dependent is the C stdio FILE*. Why isn't there a
constructor for {i/o}fstream which takes a FILE*? Shouldn't there be? That
would be platform-independent and decidedly useful. It would also reduce
wrapping a file descriptor to call fdopen() on it first.

Is there interest in this? Has someone else done it and I just don't know
about it? Does anyone want to do it? I probably will get around to it
sometime for my own purposes, but that may not be for quite a while. I'd be
inclined to do it for both FILE* and file descriptors.


Boost list run by bdawes at, gregod at, cpdaniel at, john at