Mercurial > pidgin
comparison src/util.c @ 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 | a83aaf250284 |
| children | e293d0c42ccb |
comparison
equal
deleted
inserted
replaced
| 7621:bfe3a796b2c2 | 7622:072feee65244 |
|---|---|
| 1185 } | 1185 } |
| 1186 | 1186 |
| 1187 return NULL; | 1187 return NULL; |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 int gaim_build_dir (char *path, int mode) | 1190 int gaim_build_dir (const char *path, int mode) |
| 1191 { | 1191 { |
| 1192 struct stat st; | 1192 struct stat st; |
| 1193 char *dir, **components, delim[] = { G_DIR_SEPARATOR, '\0' }; | 1193 char *dir, **components, delim[] = { G_DIR_SEPARATOR, '\0' }; |
| 1194 int cur, len; | 1194 int cur, len; |
| 1195 | 1195 |
| 1196 if (path == NULL || path[0] != G_DIR_SEPARATOR) | 1196 if (path == NULL || path[0] != G_DIR_SEPARATOR) |
| 1197 return -1; | 1197 return -1; |
| 1198 | 1198 |
| 1199 dir = g_new0(char, strlen(path) + 1); | 1199 dir = g_new0(char, strlen(path) + 1); |
| 1200 components = g_strsplit(path + 1, delim, -1); | 1200 components = g_strsplit(path, delim, -1); |
| 1201 len = 0; | 1201 len = 0; |
| 1202 for (cur = 0; components[cur] != NULL; cur++) { | 1202 for (cur = 0; components[cur] != NULL; cur++) { |
| 1203 dir[len++] = G_DIR_SEPARATOR; | 1203 if(*components[cur] == '\0') |
| 1204 continue; | |
| 1205 if(cur != 0) | |
| 1206 dir[len++] = G_DIR_SEPARATOR; | |
| 1204 strcpy(dir + len, components[cur]); | 1207 strcpy(dir + len, components[cur]); |
| 1205 len += strlen(components[cur]); | 1208 len += strlen(components[cur]); |
| 1206 if (stat(dir, &st) == 0) { | 1209 if (stat(dir, &st) == 0) { |
| 1207 if ((st.st_mode & S_IFMT) == S_IFDIR) | 1210 if ((st.st_mode & S_IFMT) == S_IFDIR) |
| 1208 continue; | 1211 continue; |
