bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 1 | #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 | |
| 10 | extern int xmkstemp(char **tmpname, char *dir); |
| 11 | |
| 12 | static 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 | |
| 28 | extern int get_fd_tabsize(void); |
| 29 | |
| 30 | extern int mkdir_p(const char *path, mode_t mode); |
| 31 | extern char *stripoff_last_component(char *path); |
| 32 | |
| 33 | #endif /* UTIL_LINUX_FILEUTILS */ |