changeset 204:5e0f4260c4f5

- Fixed a bug in the creation of the ~/.dillo directory.
author jcid
date Fri, 02 May 2008 20:01:48 +0200
parents d48ee634eb91
children 97618a4195ba
files src/dillo.cc src/dir.c src/dir.h
diffstat 3 files changed, 29 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/dillo.cc	Fri May 02 17:45:47 2008 +0200
+++ b/src/dillo.cc	Fri May 02 20:01:48 2008 +0200
@@ -21,10 +21,8 @@
 #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>
@@ -46,26 +44,6 @@
 #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));
-   } else {
-      MSG("Dillo: creating directory %s.\n", dir);
-   }
-   dFree(dir);
-}
 
 /*
  * Given a command line argument, build a DilloUrl for it.
@@ -109,12 +87,10 @@
    // 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();
+   a_Dir_check_dillorc_directory(); /* and create if not present */
    a_Dpi_init();
    a_Dns_init();
    a_Web_init();
--- a/src/dir.c	Fri May 02 17:45:47 2008 +0200
+++ b/src/dir.c	Fri May 02 20:01:48 2008 +0200
@@ -10,7 +10,10 @@
  */
 
 #include <unistd.h>
+#include <errno.h>
+#include <sys/stat.h>
 
+#include "msg.h"
 #include "../dlib/dlib.h"
 
 
@@ -46,3 +49,27 @@
    dFree(OldWorkingDirectory);
 }
 
+/*
+ * Check if '~/.dillo' directory exists.
+ * If not, try to create it.
+ */
+void a_Dir_check_dillorc_directory(void)
+{
+   char *dir;
+   struct stat st;
+
+   dir = dStrconcat(dGethomedir(), "/.dillo", NULL);
+   if (stat(dir, &st) == -1) {
+      if (errno == ENOENT) {
+         MSG("Dillo: creating directory %s.\n", dir);
+         if (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);
+}
+
--- a/src/dir.h	Fri May 02 17:45:47 2008 +0200
+++ b/src/dir.h	Fri May 02 20:01:48 2008 +0200
@@ -9,6 +9,7 @@
 void a_Dir_init(void);
 char *a_Dir_get_owd(void);
 void a_Dir_free(void);
+void a_Dir_check_dillorc_directory(void);
 
 
 #ifdef __cplusplus