C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

fstat for an open fstream

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Klaus Füller
Guest





PostPosted: Fri Sep 26, 2003 3:24 pm    Post subject: fstat for an open fstream Reply with quote



I would like to use the unix,et.al-fstat() system-call on some sort of
stream which is already open and connected to a disk file.

An example: I have an open stream and want to know the numerical
owner-id of the file associated with the stream.

I can write the code myself if someone tells me how to get the
filedescriptor that must be buried as a member attribute somewhere in
the stream-classes. Eventually all io must pass through such a
descriptor - so it _must_ exist somewhere.

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.

Any glue?

Klaus.

Back to top
Klaus Füller
Guest





PostPosted: Fri Sep 26, 2003 3:47 pm    Post subject: Re: fstat for an open fstream Reply with quote



WW schrieb:
Quote:
Klaus Füller wrote:

I would like to use the unix,et.al-fstat() system-call on some sort of
stream which is already open and connected to a disk file.

[SNIP]

Any glue?


Yep. Stick with a UNIX/Posix newsgroup Smile
Thank you.


I know how to do it in Unix and Posix but I don't know how to do it in
C++. Although I'm aware about the fact that the information I want to
get is not fully portable there must - or at least should - be a
portable way to get some of this.

So - sorry - I insist that this is the right place to ask for it.

The general question is - how do I get the underlying filedescriptor of
a stream - no matter what OS the program runs on and no matter how
opaque the returnde information might be.


Back to top
WW
Guest





PostPosted: Fri Sep 26, 2003 5:34 pm    Post subject: Re: fstat for an open fstream Reply with quote



Klaus Füller wrote:
Quote:
I would like to use the unix,et.al-fstat() system-call on some sort of
stream which is already open and connected to a disk file.
[SNIP]
Any glue?

Yep. Stick with a UNIX/Posix newsgroup :-)

http://www.slack.net/~shiva/welcome.txt

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

--
WW aka Attila



Back to top
WW
Guest





PostPosted: Fri Sep 26, 2003 5:58 pm    Post subject: Re: fstat for an open fstream Reply with quote

Klaus Füller wrote:
Quote:
WW schrieb:
Klaus Füller wrote:

I would like to use the unix,et.al-fstat() system-call on some sort
of stream which is already open and connected to a disk file.

[SNIP]

Any glue?


Yep. Stick with a UNIX/Posix newsgroup Smile
Thank you.

I know how to do it in Unix and Posix but I don't know how to do it in
C++. Although I'm aware about the fact that the information I want to
get is not fully portable there must - or at least should - be a
portable way to get some of this.

So - sorry - I insist that this is the right place to ask for it.

The general question is - how do I get the underlying filedescriptor
of a stream - no matter what OS the program runs on and no matter how
opaque the returnde information might be.

This newsgroup discusses *only* the standard C++ language. So please don't
insist(*), but go to the group/discussion forum/technical support of your
compiler/standard library implementation and ask it there.

(*) Here the answer is: you cannot do it. Only the pre-standard iostreams
had support to retrieve their file descriptor. The standard iostreams do
not support it. And any non-standard feature discussion should go to the
implementation specific discussion forums.

--
WW aka Attila



Back to top
Mike Wahler
Guest





PostPosted: Fri Sep 26, 2003 11:39 pm    Post subject: Re: [OT] fstat for an open fstream Reply with quote

"Klaus Füller" <klausf (AT) schule (DOT) de> wrote

WW schrieb:
Quote:
Klaus Füller wrote:

I would like to use the unix,et.al-fstat() system-call on some sort of
stream which is already open and connected to a disk file.

[SNIP]

Any glue?


Yep. Stick with a UNIX/Posix newsgroup Smile
Thank you.


Quote:
I know how to do it in Unix and Posix but I don't know how to do it in
C++.

It cannot be done with C++ alone. Many C++ implementations
do provide POSIX support as an 'extension', so that's a possible route.

Quote:
Although I'm aware about the fact that the information I want to
get is not fully portable

It's not portable at all from a C++ perspective.

Quote:
there must - or at least should - be a
portable way to get some of this.

Say 'should' if you like, but there is no portable way.
It "shouldn't" rain anytime I go outside, but
soemtimes it does. :-)

Quote:
So - sorry - I insist that this is the right place to ask for it.

Insist all you like, but it's not. Only ISO standard C++
is the topic here, which cannot do what you ask. Haven't
you read the welcome message at the link that "WW" provided?
It states very clearly what is and is not topical here.

Quote:
The general question is - how do I get the underlying filedescriptor of
a stream - no matter what OS the program runs on

You cannot. The form and usage of 'file descriptors'
(if even used) are necessarily dependent upon the
implementation, and by implication, the host OS.
C++ has no concept at all of 'file descriptor'.

E.g. UNIX and VMS don't handle files the same way.
But at the 'higher level' of C++ code, they can
be accessed in a uniform way by using the iostream
abstraction.

I suppose you could dig around in your implementation's
internals and figure it out, but the method you come up
with will only be valid for that implementation (might
also be for other implementations on the same platform,
but not necessarily.)

Quote:
and no matter how
opaque the returnde information might be.

'Opaqueness' is already provided by the iostreams
abstraction.

You're talking about a necessarily platform-dependent
issue. So if you want portability, you'll need to
write a module for each platform, and adjust compilation
accordingly for each.

-Mike





Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.