Re: g++: using fstat on an already open stream
From: Jerry Feldman (gaf-noSPAM_at_blu.org)
Date: 09/28/03
- Next message: pattanawadee: "How to kill all inherrit processes"
- Previous message: Victor Wagner: "Re: g++: using fstat on an already open stream"
- In reply to: Klaus Füller: "Re: g++: using fstat on an already open stream"
- Next in thread: Victor Wagner: "Re: g++: using fstat on an already open stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Sep 2003 14:12:43 GMT
On Sun, 28 Sep 2003 13:52:43 +0200
Klaus Füller <klausf@schule.de> wrote:
> Jerry Feldman wrote:
> > On Sun, 28 Sep 2003 20:44:06 +0800
> > chaoith <aaa@aaa.com> wrote:
> >
> >
> >>Klaus Füller wrote:
> >>
> >>
> >>>I know how to retrieve the information if I have the filename (call
> >>>stat()) --- but I want to use fstat() on an already open stream
> >>>without referring to the filename.
> >>
> >>Looking into stdio.h gives me the data structure of FILE.
> >>There is a data member called short _file
> ...
> >
> >
> > NO, NO. That is WRONG. NEVER do that. The FILE structure is subject
> > to change at any release. The proper way to do get the file
> > descriptor from an opened file is to use the fileno() function.
> >
> ...
> >>fstat(fileno(f), ...);
>
> Sorry, I was too unspecific. I use a 'fstream' not a FILE*. It's C++,
> after all. With <stdio.h> i would have no problems at all. But it's
> <iostream>!
>
There is an external stdio_fstream class defined in the __gnu_cxx
namespace. You can use that to associate C file descriptors and C FILEs
with C++ iostream classes.
I'm not sure if you can apply that to an already opened stream.
My comment was based on your using the C FILE structure.
The header file is /usr/include/g++/ext/stdio_filebuf.h.
You'll need to dig a bit more.
-- Jerry Feldman <gaf-nospam-at-blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
- Next message: pattanawadee: "How to kill all inherrit processes"
- Previous message: Victor Wagner: "Re: g++: using fstat on an already open stream"
- In reply to: Klaus Füller: "Re: g++: using fstat on an already open stream"
- Next in thread: Victor Wagner: "Re: g++: using fstat on an already open stream"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]