[vlc-devel] [PATCH] api: add vlc_gettmpdir
remi at remlab.net
Wed Feb 12 16:38:07 CET 2014
On Wed, 12 Feb 2014 15:49:17 +0100, Francois Cartegnie <fcvlcdev at free.fr>
> We have no function for implementation defined temporary dir, and
> is unsafe.
It is true that tempnam() is not safe in a certain respect (and obsoleted
by POSIX). But the function introduced in your patch is a lot worse in that
respect. As far as I know, mkdtemp() is the "correct" function in POSIX
land (and thus arguably, vlc_mkdtemp() should be the name).
In any case, unlike temporary files, temporary directories (and named
temporary files) are not automatically erased. As such disk space leaks
cannot be avoided. No matter how hard you try, your program can always be
killed at the wrong time. And it gets worse if /tmp is mounted in tmpfs.
So I think new VLC code should not rely on temporary directories. And so
there should be no need for a helper. tempfile() is a lot better. If that
is really Really REALLY impossible, then mkstemp() is easier to clean up
after (a mere remove()) than mkdtemp(). But it will leak.
Sent from my collocated server
More information about the vlc-devel