By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

How can I get a file descriptor from a c++ i/o stream?

P: n/a
Dear all,

Because of some reason, I must get a file descript from a c++ I/O stream,
for example: ifstream.

Under OpenUnix I have a function ifstream::fd (rdbuf->fd) to do this.
But in Linux, there is not a such function of ifstream class.
Is there not a such function in standard C++ ?
Or is there another way to get?

Thanks for your help.
Regards,
Thorsten

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thorsten Knopel wrote:
Because of some reason, I must get a file descript from a c++ I/O stream,
for example: ifstream.

Under OpenUnix I have a function ifstream::fd (rdbuf->fd) to do this.
But in Linux, there is not a such function of ifstream class.
Is there not a such function in standard C++ ?
No. In general a stream doesn't have to have anything like a "file
descriptor" in it. It's implementation-defined how streams maintain
their association with whatever is considered "a file".
Or is there another way to get?


There can be something specific to your library implementation. Have
you tried looking in the docs or asking in a newsgroup for your OS?

V
Jul 23 '05 #2

P: n/a
Victor Bazarov wrote:
It's implementation-defined how streams maintain
their association with whatever is considered "a file".


It's unspecified, not implementation defined. The implementation doesn't
have to document what it does.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.