On 3/23/13, Ihar `Philips` Filipau <[email protected]> wrote: >> (i tried to find a way to duplicate a FILE* but failed) > > How did you duplicate FILE*? > > How did the `fdopen( fileno(oldfile), mode )` failed? >
Nope. This is the right way: int new_fd = dup( fileno(oldfile) ); FILE *new_file = fdopen( new_fd, mode ); It is OK to use *NIX function here - the dup() - since deleting open file can happen only on the *NIX-like OS, Mac OS X included. Windows doesn't allow that. Correct me if I'm wrong. Tested on Linux, HP-UX and Solaris for the safety sake: the fclose() would close the dup()ed file descriptor. Though I'm not sure how to integrate that with the rest of the portable code. :) FYI. _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
