curl-library
create-dirs on win32
Date: Mon, 06 Jan 2003 23:19:27 +0000
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.
curl --create-dirs http://localhost/ -o foo\bar\file.htm
--Matthew
--- main.c.orig Thu Dec 5 19:39:00 2002
+++ main.c Mon Jan 6 15:05:14 2003
@@ -3054,6 +3054,7 @@
outdup = strdup(outfile);
dirbuildup = malloc(sizeof(char) * strlen(outfile));
+ *dirbuildup = '\0';
tempdir = strtok(outdup, DIR_CHAR);
@@ -3070,7 +3071,24 @@
else
sprintf(dirbuildup,"%s%s", DIR_CHAR, tempdir);
}
+#ifndef F_OK
+#define F_OK 0
+#endif
if (access(dirbuildup,F_OK) == -1) {
+#ifdef WIN32
+ result = CreateDirectory(dirbuildup, NULL);
+ if (!result) // mkdir returns 0 for success, opposite of
createdirectory
+ {
+ result = GetLastError();
+ fprintf(stderr,"Error 0x%x creating directory %s.\n", result,
dirbuildup);
+ result = -1;
+ break;
+ }
+ else
+ {
+ result = 0;
+ }
+#else
result = mkdir(dirbuildup,(mode_t)0000750);
if (-1 == result) {
switch (errno) {
@@ -3110,6 +3128,7 @@
}
break; /* get out of loop */
}
+#endif
}
}
tempdir = tempdir2;
_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months
http://join.msn.com/?page=dept/dialup
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
Received on 2003-01-07