Commit 34d4f313 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

filesystem: use native mkstemp() on POSIX

parent 75799939
......@@ -98,6 +98,20 @@ int vlc_openat (int dir, const char *filename, int flags, ...)
return fd;
}
int vlc_mkstemp (char *template)
{
int fd;
#ifdef HAVE_MKOSTEMP
fd = mkostemp (template, O_CLOEXEC);
#else
fd = mkstemp (template);
#endif
if (fd != -1)
fcntl (fd, F_SETFD, FD_CLOEXEC);
return fd;
}
int vlc_memfd (void)
{
int fd;
......@@ -115,16 +129,9 @@ int vlc_memfd (void)
char bufpath[] = "/tmp/"PACKAGE_NAME"XXXXXX";
#ifdef HAVE_MKOSTEMP
fd = mkostemp (bufpath, O_CLOEXEC);
#else
fd = mkstemp (bufpath);
#endif
fd = vlc_mkstemp (bufpath);
if (fd != -1)
{
fcntl (fd, F_SETFD, FD_CLOEXEC);
unlink (bufpath);
}
return fd;
}
......
......@@ -30,7 +30,6 @@
#include <vlc_common.h>
#include <vlc_fs.h>
#include <vlc_rand.h>
#include <assert.h>
......@@ -192,6 +191,9 @@ int vlc_scandir( const char *dirname, char ***namelist,
return val;
}
#if defined (_WIN32) || defined (__OS2__)
# include <vlc_rand.h>
int vlc_mkstemp( char *template )
{
static const char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
......@@ -231,3 +233,4 @@ int vlc_mkstemp( char *template )
errno = EEXIST;
return -1;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment