cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: create-dirs on win32

From: <RBramante_at_on.com>
Date: Tue, 7 Jan 2003 09:45:20 -0500

MSVC6.0 does provide mkdir(const char* dirname) (see direct.h)

                                                                                                                         
                      "Alexander J. Oss"
                      <alexoss_at_verizon.net> To: <curl-library_at_lists.sourceforge.net>
                      Sent by: cc:
                      curl-library-admin_at_lists.sour Subject: Re: create-dirs on win32
                      ceforge.net
                                                                                                                         
                                                                                                                         
                      01/07/2003 09:07 AM
                      Please respond to
                      curl-library
                                                                                                                         
                                                                                                                         

In Borland C++ Builder there's a mkdir(). CreateDirectory() is the Win32
API function eventually called by a C runtime function like mkdir(). (I'd
be stunned if MS VC++ didn't provide a mkdir().)

----- Original Message -----
From: "Daniel Stenberg" <daniel_at_haxx.se>
To: "matthew b" <mb7oo_at_hotmail.com>
Cc: "libcurl Mailing list" <curl-library_at_lists.sourceforge.net>
Sent: Tuesday, January 07, 2003 4:41 AM
Subject: Re: create-dirs on win32

On Mon, 6 Jan 2003, matthew b wrote:

> Here's a diff for a real quick modification to create-dirs so it works on
> win32. It also fixes a general 'uninitialized memory' bug. I didn't
check
> 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;
}

#else
/* system without mkdir and we have no implementation */
int mkdir(const char *pathname, mode_t mode)
{
  (void)mode; /* unused */
  (void)pathname; /* unused */
  return -1;
#endif
#endif

It'll make the code in the function create_dir_hierarchy() look a lot
nicer!

--
 Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-01-07