aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2008-04-30 22:41:54 +0200
committerjcid <devnull@localhost>2008-04-30 22:41:54 +0200
commitcf8e2bc54782dbbea1d5467f359b59a10130cbc2 (patch)
treea0d4d4f98fb6a98e6a18107597b0863fc899ec52
parent4f7e8835fc13ac9f0abb02d691d77f62e1af4a35 (diff)
- Added creation of ~/.dillo directory in main().
-rw-r--r--src/dillo.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/dillo.cc b/src/dillo.cc
index 0865f619..ac6bea23 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -21,12 +21,15 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <errno.h>
#include <time.h>
#include <signal.h>
+#include <sys/stat.h>
#include <fltk/Window.h>
#include <fltk/run.h>
+#include "msg.h"
#include "dir.h"
#include "uicmd.hh"
@@ -43,6 +46,24 @@
#include "dicache.h"
#include "cookies.h"
+/*
+ * Check if '~/.dillo' directory exists.
+ * If not, try to create it.
+ */
+static void Dillo_check_dillorc_dir(void)
+{
+ char *dir;
+ struct stat st;
+
+ dir = dStrconcat(dGethomedir(), "/.dillo", NULL);
+ if (stat(dir, &st) == -1) {
+ if (errno == ENOENT && mkdir(dir, 0700) < 0)
+ MSG("Dillo: error creating directory %s: %s\n",dir,dStrerror(errno));
+ else
+ MSG("Dillo: error reading %s: %s\n", dir, dStrerror(errno));
+ }
+ dFree(dir);
+}
/*
* Given a command line argument, build a DilloUrl for it.
@@ -86,6 +107,9 @@ int main(int argc, char **argv)
// Some OSes exit dillo without this (not GNU/Linux).
signal(SIGPIPE, SIG_IGN);
+ // Check that ~/.dillo exists, create it if it doesn't.
+ Dillo_check_dillorc_dir();
+
// Initialize internal modules
a_Dir_init();
a_Prefs_init();