Forums Assignment Help How can I recover the file name given an open stream or…

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1889
    Aakanksha
    Participant

    How can I recover the file name given an open stream or file descriptor?

    #10470
    ahwriter
    Participant

    This problem is, in general, insoluble. Under Unix, for instance, a scan of the entire disk (perhaps involving special permissions) would theoretically be required, and would fail if the descriptor were connected to a pipe or referred to a deleted file (and could give a misleading answer for a file with multiple links). It is best to remember the names of files yourself as you open them (perhaps with a wrapper function around fopen).

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.