Boost logo

Boost :

Subject: Re: [boost] File Handle and FILE* wrappers?
From: Sylvester-Bradley, Gareth (Gareth.Sylvester-Bradley_at_[hidden])
Date: 2014-11-19 07:47:01


On Wed, Nov 19, 2014 at 12:33 PM, Andrey Semashev wrote:
> On Wed, Nov 19, 2014 at 3:16 PM, Olaf van der Spek <ml_at_[hidden]> wrote:
> > Hi,
> >
> > Would there be any interest in wrappers for file handles / descriptors
> > and FILE*?
> >
> > Sometimes one needs native handles or FILE* for interoperability or
> > special features like memory mapped IO, but standard C++ doesn't
> > provide convenient RAII friendly wrappers for these.
> > The idea seems trivial yet quite useful.
> >
> > I'm aware of <boost/iostreams/device/file_descriptor.hpp> but it seems
> > to be too high-level.
> >
> > I've put a simple start for FILE* at
> > https://code.google.com/p/xbt/source/browse/trunk/xbt/misc/xbt/cfile.h
> > What do you think?
> >
> > Also posted at https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/Q4RdFSZggSE
>
> shared_ptr/unique_ptr work fine for me with FILE*, one only has to
> write a deleter. A dedicated class would be needed for POSIX file
> descriptors though.

Peter Sommerlad and Andrew L. Sandoval's unique_resource RAII proposal uses both FILE* and POSIX file descriptors as examples.
I think this is the latest revision:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf

Gareth

************************************************************************ The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony's global policies and standards


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