Boost logo

Boost :

Subject: Re: [boost] File Handle and FILE* wrappers?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-11-19 07:33:07


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.


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