diff options
author | Bruno Haible <bruno@clisp.org> | 2020-06-28 00:03:44 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-06-28 00:04:42 +0200 |
commit | 64a1a8244c07b83e5bf3eebfc6e358aa9d58c6a9 (patch) | |
tree | 1f5c7bff08cf29906cb5af84ea2637a7020149be /lib/clean-temp.c | |
parent | 73cc88eee5d39d04dcf8ac411720bf17ef7a75e4 (diff) | |
download | gnulib-64a1a8244c07b83e5bf3eebfc6e358aa9d58c6a9.tar.gz |
clean-temp: Don't force deletion of temporary files on native Windows.
* lib/clean-temp.h (open_temp, fopen_temp): Add delete_on_close
argument.
* lib/clean-temp.c (open_temp, fopen_temp): Likewise.
* NEWS: Mention the change.
* lib/javacomp.c (write_temp_file): Update.
Diffstat (limited to 'lib/clean-temp.c')
-rw-r--r-- | lib/clean-temp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/clean-temp.c b/lib/clean-temp.c index c57d658171..b9badac748 100644 --- a/lib/clean-temp.c +++ b/lib/clean-temp.c @@ -630,7 +630,7 @@ unregister_fd (int fd) /* Open a temporary file in a temporary directory. Registers the resulting file descriptor to be closed. */ int -open_temp (const char *file_name, int flags, mode_t mode) +open_temp (const char *file_name, int flags, mode_t mode, bool delete_on_close) { int fd; int saved_errno; @@ -640,7 +640,7 @@ open_temp (const char *file_name, int flags, mode_t mode) #if defined _WIN32 && ! defined __CYGWIN__ /* Use _O_TEMPORARY when possible, to increase the chances that the temporary file is removed when the process crashes. */ - if (supports_delete_on_close ()) + if (delete_on_close && supports_delete_on_close ()) fd = open (file_name, flags | _O_TEMPORARY, mode); else #endif @@ -656,7 +656,7 @@ open_temp (const char *file_name, int flags, mode_t mode) /* Open a temporary file in a temporary directory. Registers the resulting file descriptor to be closed. */ FILE * -fopen_temp (const char *file_name, const char *mode) +fopen_temp (const char *file_name, const char *mode, bool delete_on_close) { FILE *fp; int saved_errno; @@ -666,7 +666,7 @@ fopen_temp (const char *file_name, const char *mode) #if defined _WIN32 && ! defined __CYGWIN__ /* Use _O_TEMPORARY when possible, to increase the chances that the temporary file is removed when the process crashes. */ - if (supports_delete_on_close ()) + if (delete_on_close && supports_delete_on_close ()) { size_t mode_len = strlen (mode); char *augmented_mode = (char *) xmalloca (mode_len + 2); |