[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Wget MinGW/MSYS build issues

From: Ángel González
Subject: Re: [Bug-wget] Wget MinGW/MSYS build issues
Date: Thu, 14 Mar 2013 01:55:12 +0100
User-agent: Thunderbird

On 12/03/13 00:49, Alex wrote:
>  Greetings.
> Thanks for quick reply.
> During searching info about FILE_FLAG_DELETE_ON_CLOSE find that flag
> "O_TEMPORARY" work in Windows.
> What if replace mkstemp() with mkostemp()? (
> mkstemp(filename)==mkostemp(filename,0). Need to update bootstrap.conf)
> And use "mkostemp(filename, O_TEMPORARY);" or direct
> "mkostemp(filename,0x0040);"
> unlink(filename) in warc_tempname then isn't needs any more.
> It's work as should in MinGW/Win32 (temporary files exist only during
> usage).
> Can You please check it in *nix?
> Best regards, Alex
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

I would however do a
#define O_TEMPORARY 0

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
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
 /* 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 (unlink (filename) < 0)
     return NULL;
   return fdopen (fd, "wb+");

reply via email to

[Prev in Thread] Current Thread [Next in Thread]