Oh, cool.
That should work. I saw that mkostemp() was a gnu extension (thus
non-portable), and didn't think in checking if it was available through
gnulib.
I would however do a
#ifndef O_TEMPORARY
#define O_TEMPORARY 0
#endif
(...)
int fd = mkostemp (filename,O_TEMPORARY);
That 0x0040 magic number could have bad effects on some systems.
The unlink() won't be needed for Windows, but will still be needed on
Unix systems.
Modifying your patch a bit, I propose the following (tested on Linux):
diff --git a/bootstrap.conf b/bootstrap.conf
index efb1bc2..516bbb6 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -52,6 +52,7 @@ maintainer-makefile
mbtowc
mkdir
mkstemp
+mkostemp
crypto/md5
crypto/sha1
pipe
diff --git a/src/warc.c b/src/warc.c
index fb506a7..7c9fd64 100644
--- a/src/warc.c
+++ b/src/warc.c
@@ -1134,6 +1134,10 @@ warc_close (void)
}
}
+#ifndef O_TEMPORARY
+#define O_TEMPORARY 0
+#endif
+
/* Creates a temporary file for writing WARC output.
The temporary file will be created in opt.warc_tempdir.
Returns the pointer to the temporary file, or NULL. */
@@ -1144,12 +1148,14 @@ warc_tempfile (void)
if (path_search (filename, 100, opt.warc_tempdir, "wget", true) == -1)
return NULL;
- int fd = mkstemp (filename);
+ int fd = mkostemp (filename, O_TEMPORARY);
if (fd < 0)
return NULL;
+#if !O_TEMPORARY
if (unlink (filename) < 0)
return NULL;
+#endif
return fdopen (fd, "wb+");
}