Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Finding the name of a file Date: Wed, 20 Jan 2021 09:11:40 -0800 Organization: A noiseless patient Spider Lines: 37 Message-ID: <868s8no7n7.fsf@linuxsc.com> References: <0fca7756-4bc1-4972-83a2-ee108a4e6ab2n@googlegroups.com> <1bpn2ayun0.fsf@pfeifferfamily.net> <87eeip696t.fsf@nosuchdomain.example.com> <864kjiozlz.fsf@linuxsc.com> <1bsg71y8gk.fsf@pfeifferfamily.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="b1fd427021f152ca5ff6680f6ccee516"; logging-data="30027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+a6i1S6ZDWSxnuuVohg7pbYr5BjXxw1o4=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:QxTuD72oA8uX5jxSIAbbcMr9COg= sha1:9rLj9hgx04GokqGccYwZV5Q/Rk0= Xref: csiph.com comp.lang.c:158487 Jorgen Grahn writes: > On Sat, 2021-01-16, Joe Pfeiffer wrote: > >> Jorgen Grahn writes: >> >>> On Fri, 2021-01-15, Tim Rentsch wrote: >>> >>>> I want to know if there is any function that takes as >>>> parameter the file pointer fp and returns the name of >>>> the file "example.txt" and the mode "r". >>>> >>>> I don't see anything there that says he is asking (only) about >>>> the standard C library. What he wants to know is about "any >>>> function". Are you referring to some other comment that I may >>>> have missed? >>> >>> No, that's what I read, and combined with the fact that he asked in >>> comp.lang.c. If he had asked in comp.unix.programmer, I suppose there >>> could have been such a function in a Unix libc. >> >> To have simply said "no" if in fact there were a way to do it (even if >> not in the C standard library) would have been pretty obnoxious. Much >> better to answer "no, and it may not even be possible. Here's a way to >> approximate it", as pretty much everybody did. > > Much better IMO to reply "no; do you want it, and if so for what > purpose?" I suggest something like this: "What I think you're asking is for any function that will give you the information you're looking for. There is no such function in purely standard C, but there are some functions that may be what you're looking for in Unix or Posix environments. Some examples are (names of candidates here). Does this help answer your question, or if not is there more you can say about what it is you're trying to do?"