aboutsummaryrefslogtreecommitdiffstats
path: root/src/libposixplz/mkntemp.c
blob: 42d542bc76bd6dc9cd12e0171f386f82c2e8968e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <unistd.h>
#include <errno.h>

#include <skalibs/posixplz.h>

static int f (char const *fn, mode_t mode, void *data)
{
  (void)mode ;
  (void)data ;
  return access(fn, F_OK) == 0 ? (errno = EEXIST, -1) :
    errno == ENOENT ? (errno = 0, 0) : -1 ;
}

int mkntemp (char *s)
{
  return mkfiletemp(s, &f, 0, 0) ;
}