This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: more detailed io state; new_handler and thread safety
- From: Matthias Weiss <matthias dot weiss at inode dot at>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 5 Apr 2002 19:31:29 +0200
- Subject: Re: more detailed io state; new_handler and thread safety
- References: <20020404001715.A512@matthias.weiss@inode.at> <Pine.SOL.3.91.1020404113250.25512A-100000@taarna.cygnus.com>
- Reply-to: matthias dot weiss at inode dot at
On Thu, Apr 04, 2002 at 11:36:22AM -0800, Benjamin Kosnik wrote:
>
> > 1.) How can I determine what caused a stream to get
> > the ios_base::failbit or ios_base::badbit?
> > E.g. how can I find out if opening a file failed due
> > to permission problems?
>
> You could check for state after open.
>
> std::ifstream ifs1;
> ifs1.open(name_01);
> if (ifs1.rdstate() == std::ios_base::failbit)
>
Well, if I read this right, this tells me that *SOMETHING* went
wrong while opening the file. But I'd like to know whether the
error arose due to a wrong file permissions, or maybe the file
doesn't exist or whatever. How do I get this out of the "failbit"?
matthias