tmpfile-util: turn last parameter of link_tmpfile() into a proper flags

This changes a boolean param into a proper bitflag field.

Given this only defines a single flag for now this doesn't look like
much of an improvement. But we'll add another flag shortly, where it
starts to make more sense.
This commit is contained in:
Lennart Poettering
2023-06-13 09:40:53 +02:00
parent 0f85a0d38f
commit 27e18c23bc
8 changed files with 24 additions and 19 deletions
+9 -4
View File
@@ -29,11 +29,16 @@ static inline int open_tmpfile_linkable(const char *target, int flags, char **re
}
int fopen_tmpfile_linkable(const char *target, int flags, char **ret_path, FILE **ret_file);
int link_tmpfile_at(int fd, int dir_fd, const char *path, const char *target, bool replace);
static inline int link_tmpfile(int fd, const char *path, const char *target, bool replace) {
return link_tmpfile_at(fd, AT_FDCWD, path, target, replace);
typedef enum LinkTmpfileFlags {
LINK_TMPFILE_REPLACE = 1 << 0,
} LinkTmpfileFlags;
int link_tmpfile_at(int fd, int dir_fd, const char *path, const char *target, LinkTmpfileFlags flags);
static inline int link_tmpfile(int fd, const char *path, const char *target, LinkTmpfileFlags flags) {
return link_tmpfile_at(fd, AT_FDCWD, path, target, flags);
}
int flink_tmpfile(FILE *f, const char *path, const char *target, bool replace);
int flink_tmpfile(FILE *f, const char *path, const char *target, LinkTmpfileFlags flags);
int mkdtemp_malloc(const char *template, char **ret);
int mkdtemp_open(const char *template, int flags, char **ret);