diff options
author | Bruno Haible <bruno@clisp.org> | 2020-07-04 18:06:52 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-07-04 18:06:52 +0200 |
commit | 36d4b7ed93c3c29505f939de6725b7f68b860fa5 (patch) | |
tree | 39b4536f94f35f5fc1961b03d7fa6310a0620ce3 /lib/clean-temp.h | |
parent | 564370e171d3e503d10463288bee2ff5273b2a33 (diff) | |
download | gnulib-36d4b7ed93c3c29505f939de6725b7f68b860fa5.tar.gz |
clean-temp: Add support for temporary files with given mode.
* lib/clean-temp.h (gen_register_open_temp): Add mode argument.
* lib/clean-temp.c (struct try_create_file_params): New type.
(try_create_file): New function.
(gen_register_open_temp): Add mode argument. Use try_tempname instead of
gen_tempname.
Diffstat (limited to 'lib/clean-temp.h')
-rw-r--r-- | lib/clean-temp.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/clean-temp.h b/lib/clean-temp.h index df7e7442c0..d660b18cb6 100644 --- a/lib/clean-temp.h +++ b/lib/clean-temp.h @@ -164,10 +164,12 @@ extern FILE * fopen_temp (const char *file_name, const char *mode, FILE_NAME_TMPL must match the rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix). The name constructed does not exist at the time of the call. FILE_NAME_TMPL is overwritten with the result. + A safe choice for MODE is S_IRUSR | S_IWUSR, a.k.a. 0600. Registers the file for deletion. - Opens the file, with the given FLAGS and mode 0600. + Opens the file, with the given FLAGS and mode MODE. Registers the resulting file descriptor to be closed. */ -extern int gen_register_open_temp (char *file_name_tmpl, int suffixlen, int flags); +extern int gen_register_open_temp (char *file_name_tmpl, int suffixlen, + int flags, mode_t mode); /* Close a temporary file. FD must have been returned by open_temp or gen_register_open_temp. |