Boost logo

Boost :

Subject: Re: [boost] File Handle and FILE* wrappers?
From: Nat Goodspeed (nat_at_[hidden])
Date: 2014-12-16 07:53:01


On Mon, Dec 15, 2014 at 9:29 PM, Rob Stewart <robertstewart_at_[hidden]> wrote:

> On December 15, 2014 6:25:44 PM EST, Nat Goodspeed <nat_at_[hidden]> wrote:

>>Interestingly, I just stumbled across a bit of live legacy code that
>>relies on __gnu_cxx::stdio_filebuf to allow constructing an istream or
>>ostream from an open FILE*. This does not port to libc++.

>>What surprised me was that I could find no support for FILE* in
>>Boost.Iostreams. Writing a streambuf isn't rocket science, but I would
>>think that this particular use case would be common enough to warrant
>>library support.

> FILE* is buffered and streambuf provides buffering. You can create a streambif that doesn't actually do any buffering, but it is contrary to the purpose of one.

Very true. I surmise that the purpose of this functionality is to
provide an adapter between code that opens a FILE* and code that wants
to write to a std::ostream (or read from a std::istream).

Another approach would be to dig into the provider of the FILE* and
rewrite its own file handling in terms of fstream. That may or may not
be more work than writing a streambuf adapter from scratch. It would
certainly be more work than simply using a FILE*-based streambuf from
a library, which is what I was hoping to find.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk