Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!stan!dce From: dce@Solbourne.COM (David Elliott) Newsgroups: comp.unix.wizards Subject: Re: how can I get filename from file descriptor? Message-ID: <2050@marvin.Solbourne.COM> Date: 22 Aug 89 16:58:58 GMT References: <20613@adm.BRL.MIL> <1019@virtech.UUCP> <20482@sequent.UUCP> Reply-To: dce@Solbourne.com (David Elliott) Organization: Solbourne Computer Inc., Longmont, Colorado Lines: 36 In article <20482@sequent.UUCP> paulr@crg3.UUCP (Paul Reger) writes: > >The solutions to this problems are very dissatisfying. I think the >object oriented approach should be adopted here to file operations. >What I mean is this: > >modify fopen() and the FILE structure in the following ways: > >Have the FILE structure have a name field in it: > > char *name; ... But this doesn't really solve the problem in the general case, and it's something one can easily implement without changing stdio. I mean, if I called fopen() to open the file, I knew the name at some point, and could have saved it in a table myself. Most people who ask this question want to know the name of the file associated with a file descriptor that they inherited via redirection, in which case the name isn't known, and there may indeed be no name associated with the file (pipes and unlinked temp files are the typical examples). Also, not everyone uses stdio (whether they should or not is a separate issue). The reason the solutions are dissatisfying, even after talking about them for the last 10 years, is that there really isn't a good solution unless you fundamentally change Unix. -- David Elliott dce@Solbourne.COM ...!{uunet,boulder,nbires,sun}!stan!dce "I had a dream that my kids had been reparented." - Tom LaStrange