Can I get the access mode of a `FILE*`?
问题 I have to duplicate a FILE* in C on Mac OS X (using POSIX int file descriptors all the way is unfortunately out of question), so I came up with the following function: static FILE* fdup(FILE* fp, const char* mode) { int fd = fileno(fp); int duplicated = dup(fd); return fdopen(duplicated, mode); } It works very well, except it has that small ugly part where I ask for the file mode again, because fdopen apparently can't determine it itself. This issue isn't critical, since basically, I'm just