+2020-06-27 Bruno Haible <bruno@clisp.org>
+
+ 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.
+
2020-06-27 Bruno Haible <bruno@clisp.org>
fatal-signal: Make multithread-safe.
Date Modules Changes
+2020-06-27 clean-temp The functions open_temp, fopen_temp now take a
+ 'bool delete_on_close' argument. If in doubt, pass
+ false.
+
2020-06-27 tempname The link requirements of these modules are changed
mkdtemp from empty to $(LIB_GETRANDOM).
mkstemp
/* 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;
#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
/* 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;
#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);
extern int cleanup_temp_dir (struct temp_dir *dir);
/* Open a temporary file in a temporary directory.
- Registers the resulting file descriptor to be closed. */
-extern int open_temp (const char *file_name, int flags, mode_t mode);
-extern FILE * fopen_temp (const char *file_name, const char *mode);
+ Registers the resulting file descriptor to be closed.
+ DELETE_ON_CLOSE indicates whether the file can be deleted when the resulting
+ file descriptor or stream is closed. */
+extern int open_temp (const char *file_name, int flags, mode_t mode,
+ bool delete_on_close);
+extern FILE * fopen_temp (const char *file_name, const char *mode,
+ bool delete_on_close);
/* Close a temporary file in a temporary directory.
Unregisters the previously registered file descriptor. */
FILE *fp;
register_temp_file (tmpdir, file_name);
- fp = fopen_temp (file_name, "we");
+ fp = fopen_temp (file_name, "we", false);
if (fp == NULL)
{
error (0, errno, _("failed to create \"%s\""), file_name);