blob: b4e0a4adb491ca227238e65e7ae847f64da035e0 [file] [log] [blame]
bigbiff bigbiffe60683a2013-02-22 20:55:50 -05001#ifndef UTIL_LINUX_FILEUTILS
2#define UTIL_LINUX_FILEUTILS
3
bigbiff7b4c7a62015-01-01 19:44:14 -05004#include <stdio.h>
5#include <fcntl.h>
6#include <unistd.h>
7
8#include "c.h"
9
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050010extern int xmkstemp(char **tmpname, char *dir);
11
12static inline FILE *xfmkstemp(char **tmpname, char *dir)
13{
14 int fd;
15 FILE *ret;
bigbiff7b4c7a62015-01-01 19:44:14 -050016
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050017 fd = xmkstemp(tmpname, dir);
bigbiff7b4c7a62015-01-01 19:44:14 -050018 if (fd == -1)
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050019 return NULL;
bigbiff7b4c7a62015-01-01 19:44:14 -050020
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050021 if (!(ret = fdopen(fd, "w+"))) {
22 close(fd);
23 return NULL;
24 }
25 return ret;
26}
27
28extern int get_fd_tabsize(void);
29
bigbiff7b4c7a62015-01-01 19:44:14 -050030extern int mkdir_p(const char *path, mode_t mode);
31extern char *stripoff_last_component(char *path);
32
bigbiff bigbiffe60683a2013-02-22 20:55:50 -050033#endif /* UTIL_LINUX_FILEUTILS */