FILE *foo to filename?

Paul John Falstad pfalstad at phoenix.Princeton.EDU
Wed Oct 31 15:06:40 AEST 1990


In article <272cd831-5edcomp.lang.c at vpnet.chi.il.us> akcs.dgy at vpnet.chi.il.us (Donald Yuniskis) writes:
>Given:
>  FILE *foo;
>whats a clean way of obtaining the filename assoctiated with foo?
>An initial thought is stat(fileno(foo)..) to get inode number but then what?
>Any help is appreciated... thx, dgy

You don't want to do this.  If the file's link count is more than one,
you can't do it at all, and even if the file's link count is equal to
one, you'd have to search the whole file system to get the right
filename.  Even assuming you know that FILE *foo is actually a file and
not a pipe, socket, etc.

(This is actually a comp.unix.* question.)

--
Paul Falstad, pfalstad at phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD
I would bring back hanging, and go into rope.  I would cut off the more
disreputable parts of the body and use the space for playing fields.



More information about the Comp.lang.c mailing list