[Frugalware-darcs] setup: util: new function: makepath()
VMiklos
vmiklos at frugalware.org
Thu Mar 30 00:49:49 CEST 2006
[util: new function: makepath()
VMiklos <vmiklos at frugalware.org>**20051111223241] {
hunk ./src/util.c 25
+#include <sys/stat.h>
hunk ./src/util.c 142
+}
+
+int makepath(char *path)
+{
+ char *orig, *str, *ptr;
+ char full[PATH_MAX] = "";
+ mode_t oldmask;
+
+ oldmask = umask(0000);
+
+ orig = strdup(path);
+ str = orig;
+ while((ptr = strsep(&str, "/")))
+ if(strlen(ptr))
+ {
+ struct stat buf;
+
+ strcat(full, "/");
+ strcat(full, ptr);
+ if(stat(full, &buf))
+ if(mkdir(full, 0755))
+ {
+ free(orig);
+ umask(oldmask);
+ return(1);
+ }
+ }
+ free(orig);
+ umask(oldmask);
+ return(0);
hunk ./src/util.h 43
+int makepath(char *path);
}
More information about the Frugalware-darcs
mailing list