changeset 7622:072feee65244

[gaim-migrate @ 8246] this doesn't seem to break directory creation on *NIX, and I think it might fix it for win32, so here goes nothin' committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 24 Nov 2003 06:50:20 +0000
parents bfe3a796b2c2
children 5381f96fc185
files src/util.c src/util.h
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.c	Mon Nov 24 03:05:16 2003 +0000
+++ b/src/util.c	Mon Nov 24 06:50:20 2003 +0000
@@ -1187,7 +1187,7 @@
 	return NULL;
 }
 
-int gaim_build_dir (char *path, int mode)
+int gaim_build_dir (const char *path, int mode)
 {
 	struct stat st;
 	char *dir, **components, delim[] = { G_DIR_SEPARATOR, '\0' };
@@ -1197,10 +1197,13 @@
 		return -1;
 
 	dir = g_new0(char, strlen(path) + 1);
-	components = g_strsplit(path + 1, delim, -1);
+	components = g_strsplit(path, delim, -1);
 	len = 0;
 	for (cur = 0; components[cur] != NULL; cur++) {
-		dir[len++] = G_DIR_SEPARATOR;
+		if(*components[cur] == '\0')
+			continue;
+		if(cur != 0)
+			dir[len++] = G_DIR_SEPARATOR;
 		strcpy(dir + len, components[cur]);
 		len += strlen(components[cur]);
 		if (stat(dir, &st) == 0) {
--- a/src/util.h	Mon Nov 24 03:05:16 2003 +0000
+++ b/src/util.h	Mon Nov 24 06:50:20 2003 +0000
@@ -254,15 +254,14 @@
 /**
  * Builds a complete path from the root, making any directories along
  * the path which do not already exist.
- * 
+ *
  * @param path The path you wish to create.  Note that it must start
  *        from the root or this function will fail.
- * 
  * @param mode Unix-style permissions for this directory.
- * 
+ *
  * @return 0 for success, nonzero on any error.
  */
-int gaim_build_dir(char *path, int mode);
+int gaim_build_dir(const char *path, int mode);
 
 /**
  * Creates a temporary file and returns a file pointer to it.