Assume I have a file pointer FILE* myfile
. Is there a way to retrieve the name of the file where myfile
is reading from or writing to?
views:
57answers:
2
+1
A:
Not in any CRT implementation that I've ever seen. It is useless info, you already have to supply the file name to get a FILE*. You could probably dig an operating system handle out of the FILE structure although you might need to hop through a file descriptor table. Your next problem is then the operating system support you'd need to map a file handle back to a file name. That should be difficult too.
Hans Passant
2010-02-11 09:56:45
A:
I found a nice example that uses an overwritten struct MyFile: How to get filename from a FILE*
Simon Linder
2010-02-11 10:39:36