Getting the pathname from a FILE*.

Chris Calabrese[rs] cjc at ulysses.homer.nj.att.com
Sun Jul 10 06:15:24 AEST 1988


In article <651 at umb.umb.edu>, karl at umb.umb.edu (Karl Berry.) writes:
> 
> The title says it all. Am I missing something obvious?
> The pathname doesn't seem to be a field in either the
> _iobuf or the structure returned by stat.
> ttyname or ctermid will give you the pathname
> of your terminal, but I want the pathname of an
> arbitrary FILE* I have fopen. Or am I missing some
> reason why this is not feasible?


If _you_ have fopened the file, then _you_ already know
what the name is (just have it sitting around in your program),
but if the file is inheritted(sp?) how do you even know it's a file???

If you rsh or rlogin, then the stdin to any process created on the
remote machine is a socket (mabee it's something similar, but you get
the idea), or a stream (ditto) for sysV.

Even if you don't have any kind of a network, then stdin could be
a pipe, which has no name for unnamed pipes.  These are, infact, files
in most versions of sysV, but they have no names, just inodes.

-- 
	Christopher Calabrese
	AT&T Bell Laboratories
	ulysses!cjc



More information about the Comp.unix.wizards mailing list