开发者

Retrieving the name of the file that is associated with a file pointer

Assume I have a file pointer FILE* myfile. Is there a way to retrieve the n开发者_如何学Pythoname of the file where myfile is reading from or writing to?


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.


I found a nice example that uses an overwritten struct MyFile: How to get filename from a FILE*

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜