2012-02-29 15:58:51 +01:00
|
|
|
#ifndef UTIL_LINUX_FILEUTILS
|
|
|
|
#define UTIL_LINUX_FILEUTILS
|
|
|
|
|
2014-12-05 15:30:04 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "c.h"
|
|
|
|
|
2012-06-02 19:31:30 +02:00
|
|
|
extern int xmkstemp(char **tmpname, char *dir);
|
2012-02-29 15:58:51 +01:00
|
|
|
|
2012-06-02 19:31:30 +02:00
|
|
|
static inline FILE *xfmkstemp(char **tmpname, char *dir)
|
2012-03-10 12:29:35 +01:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
FILE *ret;
|
2014-06-18 12:57:42 +02:00
|
|
|
|
2012-06-02 19:31:30 +02:00
|
|
|
fd = xmkstemp(tmpname, dir);
|
2014-06-18 12:57:42 +02:00
|
|
|
if (fd == -1)
|
2012-03-10 12:29:35 +01:00
|
|
|
return NULL;
|
2014-06-18 12:57:42 +02:00
|
|
|
|
2013-04-03 16:12:34 +02:00
|
|
|
if (!(ret = fdopen(fd, "w+" UL_CLOEXECSTR))) {
|
2012-03-10 12:29:35 +01:00
|
|
|
close(fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-23 13:52:41 +02:00
|
|
|
|
2015-06-06 06:19:05 +02:00
|
|
|
extern int dup_fd_cloexec(int oldfd, int lowfd);
|
2012-04-23 13:52:41 +02:00
|
|
|
extern int get_fd_tabsize(void);
|
|
|
|
|
2014-06-09 10:59:18 +02:00
|
|
|
extern int mkdir_p(const char *path, mode_t mode);
|
2014-06-09 11:54:32 +02:00
|
|
|
extern char *stripoff_last_component(char *path);
|
2014-06-09 10:59:18 +02:00
|
|
|
|
2012-04-23 13:52:41 +02:00
|
|
|
#endif /* UTIL_LINUX_FILEUTILS */
|