Boost logo

Boost :

Subject: Re: [boost] possible problem with boost::iostreams::file_descriptor
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-06-11 09:56:45


On Thu, Jun 11, 2009 at 8:50 AM, Eric MALENFANT <
Eric.Malenfant_at_[hidden]> wrote:

> Zachary Turner wrote:
> > Eric MALENFANT wrote:
> >> Zachary Turner wrote:
> >>> Otherwise following
> >>> code (Windows) asserts, even though I don't think it should:
> >>>
> >>> bool is_open(HANDLE h) { return h && h!=INVALID_HANDLE_VALUE;}
> >>>
> >>> HANDLE h = ::CreateFile("C:\\autoexec.bat", GENERIC_READ,
> >>> FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRI
> >>> BUTE_NORMAL,NULL);
> >>>
> >>> boost::iostreams::file_descriptor fd(h, false);
> >>>
> >>> BOOST_ASSERT(fd.is_open() == is_open(h));
> >>>
> >> Wouldn't changing:
> >> bool is_open() const { return pimpl_->flags_ != 0; } to:
> >> bool is_open() const { return pimpl_->handle_ != -1; }
> >> be a better and/or simpler fix?
> >>
> > I blame the fact that it was 1 AM when I wrote that. Not really sure
> > what I was thinking tbh :D
>
> ... and I blame the fact that I was not wearing my glasses while
> checking if my reply was redundant:
>
> eg wrote:
> > I think there may be a related bug report :
> > https://svn.boost.org/trac/boost/ticket/2817
>
> The ticket eg refers to also suggests to "fix" is_open() by validating
> handle_'s value.
>
> > Although I think it should compare
> > against both -1 and 0, since neither indicates a valid handle.
>
> For a Windows HANDLE maybe, but ain't 0 a valid file descriptor value (I
> tought it was stdin)?
> ______________________________
>

Yea it would have to be #ifdef'd around BOOST_IOSTREAMS_WINDOWS or whatever
the define is called.


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