cURL / Mailing Lists / curl-library / Single Mail


Re: create-dirs on win32

From: matthew b <>
Date: Tue, 07 Jan 2003 22:57:12 +0000

The stdio functions are typically provided by the language provider on
windows. So when you build with Microsoft Visual C++, you're using the "CRT"
or C run-time they provided. This is also related to why you can't pass
file* streams. Other systems (borland, cygwin, etc) will have different

It does look like direct.h (as mentioned in someone else's reply) contains a
version of mkdir, though it doesn't have support for the mode; that would be
easy to workaround (just don't pass it, or define a macro or function to
remove it.).

So my current version is as follows; I don't have time to do any more with
this, or check if errno is set, but it makes things quite a bit cleaner

1) after the malloc, still set dirbuild[0] = '\0'; otherwise leave
create_dir_hierarchy alone.

2) somewhere (I stuck it in the #ifdef WIN32 at the top of the file, you may
want to put it elsewhere, and only for VC6), add the following:

#ifdef whatever-the-right-thing-is
#include <direct.h>
#define F_OK 0
// you might want to split this into declaration/definition, i just threw it
in main.c and thus didn't care.
// you might to use better name than mkdirWIN32hack. maybe mkdirNoMode
int mkdirWIN32hack(const char * sz, int mode)
    return mkdir(sz);
#define mkdir mkdirWIN32hack
#define mode_t int


>From: Daniel Stenberg <>
>To: matthew b <>
>CC: libcurl Mailing list <>
>Subject: Re: create-dirs on win32 Date: Tue, 7 Jan 2003 10:41:46 +0100
>MIME-Version: 1.0
>Received: from ([]) by
> with Microsoft SMTPSVC(5.0.2195.5600); Tue, 7 Jan
>2003 01:41:47 -0800
>Received: from localhost (dast_at_localhost)by (8.9.3/8.9.1)
>with ESMTP id KAA11700;Tue, 7 Jan 2003 10:41:46 +0100 (MET)
>X-Authentication-Warning: dast owned process doing -bs
>In-Reply-To: <>
>Message-ID: <>
>References: <>
>X-OriginalArrivalTime: 07 Jan 2003 09:41:47.0933 (UTC)
>On Mon, 6 Jan 2003, matthew b wrote:
> > Here's a diff for a real quick modification to create-dirs so it works
> > win32. It also fixes a general 'uninitialized memory' bug. I didn't
> > to see if the malloc succeeds, it looks like that's only done
> > inconsistently. I also didn't make any attempt at picking which error
> > happened to display to the user. I haven't tested the error condition at
> > all, just the simple test below.
>So mkdir() is not available in Windows?
>Could you then please rewrite your patch to instead make a function that
>looks and works like the unix version? Like this:
>(and add #define HAVE_MKDIR in the src/config-win32.h first)
>#ifndef HAVE_MKDIR
>#ifdef WIN32
>int mkdir(const char *pathname, mode_t mode)
> int result;
> (void)mode; /* unused */
> result = CreateDirectory(pathname, NULL);
> /* mkdir returns 0 for success, opposite of CreateDirectory() */
> return result?0:-1;
>/* system without mkdir and we have no implementation */
>int mkdir(const char *pathname, mode_t mode)
> (void)mode; /* unused */
> (void)pathname; /* unused */
> return -1;
>It'll make the code in the function create_dir_hierarchy() look a lot
> Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.

Add photos to your e-mail with MSN 8. Get 2 months FREE*.

This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
Received on 2003-01-08