[poppler] UniqueFileStream and deleted files
Ihar `Philips` Filipau
thephilips at gmail.com
Sat Mar 23 10:59:02 PDT 2013
On 3/23/13, Ihar `Philips` Filipau <thephilips at gmail.com> 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.
More information about the poppler
mailing list