blob: 3353f69a07ffd91c4b1262d9e53c1ef86a564c2c [file] [log] [blame]
bigbiff7b4c7a62015-01-01 19:44:14 -05001#ifndef UTIL_LINUX_FILEUTILS
2#define UTIL_LINUX_FILEUTILS
3
4#include <stdio.h>
5#include <fcntl.h>
6#include <unistd.h>
7
8#include "c.h"
9
10extern int xmkstemp(char **tmpname, char *dir);
11
12static inline FILE *xfmkstemp(char **tmpname, char *dir)
13{
14 int fd;
15 FILE *ret;
16
17 fd = xmkstemp(tmpname, dir);
18 if (fd == -1)
19 return NULL;
20
21 if (!(ret = fdopen(fd, "w+" UL_CLOEXECSTR))) {
22 close(fd);
23 return NULL;
24 }
25 return ret;
26}
27
28extern int get_fd_tabsize(void);
29
30extern int mkdir_p(const char *path, mode_t mode);
31extern char *stripoff_last_component(char *path);
32
33#endif /* UTIL_LINUX_FILEUTILS */