[rtmpdump] rtmpsuck duplicate filename patch

Andy Goth andrew.m.goth at gmail.com
Sun Apr 1 23:12:29 CEST 2012


On 4/1/2012 3:44 PM, Andy Goth wrote:
> On 4/1/2012 10:47 AM, Howard Chu wrote:
>> The patch probably addresses a real problem, but the patch is not
>> portable enough; it won't work on Win32.
>
> What part is nonportable? Is it the readdir() stuff? I do have access
> to a MinGW environment on Windows; I could try implementing an
> alternative, if MinGW is your Win32 target.

One thing came to mind.  Instead of readdir() and friends, if I could
specify the O_EXCL option to fopen(), I'd know if the file already
exists, then would change the filename and try again.  Trouble is,
unlike open(), fopen() doesn't take an O_EXCL option.  glibc fopen()
supports an "x" mode string which adds O_EXCL to the underlying open()
call, but that's not portable.  How about using open() directly?  open()
yields a file descriptor, not a stream (a.k.a. FILE) pointer, so either
use fdopen() to convert (again, nonportable) or switch from fwrite() to
write() (is that portable enough?).

-- 
Andy Goth | <andrew.m.goth/at/gmail/dot/com>


More information about the rtmpdump mailing list