aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dillo.cc26
-rw-r--r--src/dir.c27
-rw-r--r--src/dir.h1
3 files changed, 29 insertions, 25 deletions
diff --git a/src/dillo.cc b/src/dillo.cc
index 324940c0..b71af0b4 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -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 @@ 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();
+ a_Dir_check_dillorc_directory(); /* and create if not present */
a_Dpi_init();
a_Dns_init();
a_Web_init();
diff --git a/src/dir.c b/src/dir.c
index b824d8d3..f7b2644d 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -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 @@ void a_Dir_free(void)
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);
+}
+
diff --git a/src/dir.h b/src/dir.h
index 580122f0..19d69713 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -9,6 +9,7 @@ extern "C" {
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