File: tempfile.c

package info (click to toggle)
bcron 0.11-23
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 796 kB
  • sloc: sh: 3,155; ansic: 2,416; makefile: 34
file content (23 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bglibs/sysdeps.h>
#include <unistd.h>

#include <bglibs/path.h>

#include "bcron.h"

str tempname = {0,0,0};

static void cleanup(void)
{
  if (tempname.len > 0)
    unlink(tempname.s);
}

int tempfile(const char* prefix)
{
  if (tempname.s == 0)
    atexit(cleanup);
  else
    cleanup();
  return path_mktemp(prefix, &tempname);
}