+int create_path(const char *path)
+{
+ char p[NAME_SIZE];
+ char *pos;
+ struct stat stats;
+
+ strcpy (p, path);
+ pos = strrchr(p, '/');
+ if (pos == p || pos == NULL)
+ return 0;
+
+ while (pos[-1] == '/')
+ pos--;
+
+ pos[0] = '\0';
+
+ dbg("stat '%s'\n", p);
+ if (stat (p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
+ return 0;
+
+ if (create_path (p) != 0)
+ return -1;
+
+ dbg("mkdir '%s'\n", p);
+ return mkdir(p, 0755);
+}
+