]> jfr.im git - irc/quakenet/newserv.git/commitdiff
core: Create the data directory if it doesn't already exist.
authorGunnar Beutner <redacted>
Mon, 12 Aug 2013 01:45:00 +0000 (03:45 +0200)
committerGunnar Beutner <redacted>
Mon, 12 Aug 2013 01:45:00 +0000 (03:45 +0200)
core/main.c

index e958c9f034c651297391b8fe96093c8473087426..dfbd7dfe234c366800d6edd1b20cc26e48870219 100644 (file)
@@ -13,6 +13,9 @@
 #include <string.h>
 #include <time.h>
 #include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
 #include <signal.h>
 #include <unistd.h>
 
@@ -56,6 +59,12 @@ int main(int argc, char **argv) {
 
   initconfig(config);
 
+  /* modules can rely on this directory always being there */
+  if (mkdir("data", 0700) < 0 && errno != EEXIST) {
+    perror("mkdir");
+    return 1;
+  }
+
   /* Loading the modules will bring in the bulk of the code */
   initmodules();
   signal(SIGINT, siginthandler);