summary refs log tree commit diff stats
path: root/src/common/hexchat.c
diff options
context:
space:
mode:
authorDiogo Sousa <diogogsousa@gmail.com>2013-05-13 01:58:08 +0100
committerDiogo Sousa <diogogsousa@gmail.com>2013-05-13 01:58:08 +0100
commitd9d05e83ba9975959607302c45a631ee80a2d21e (patch)
treebc3c00f46be10abe25e34033794a3b59a34fc977 /src/common/hexchat.c
parent61ed0829bd57fc60cc7e08538f20b8277c74f90c (diff)
Restructured a fair bit of cfgfiles.c. Besides making the code cleaner this allows
for better error handling (in fact the error message of check_prefs_dir () whould
make hexchat abort).
Diffstat (limited to 'src/common/hexchat.c')
-rw-r--r--src/common/hexchat.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/common/hexchat.c b/src/common/hexchat.c
index 6d624133..0546f599 100644
--- a/src/common/hexchat.c
+++ b/src/common/hexchat.c
@@ -1013,9 +1013,10 @@ hexchat_execv (char * const argv[])
 #endif
 }
 
-void
-set_locale(void)
+static void
+set_locale (void)
 {
+#ifdef WIN32
 	const char const *langs[]={
 		"af", "sq", "am", "ast", "az", "eu", "be", "bg", "ca", "zh_CN",   /* 0 .. 9   */
 		"zh_TW", "cs", "da", "nl", "en_GB", "en", "et", "fi", "fr", "gl", /* 10 .. 19 */
@@ -1034,6 +1035,7 @@ set_locale(void)
 		strcat (hexchat_lang, "en");
 
 	putenv (hexchat_lang);
+#endif
 }
 
 int
@@ -1073,12 +1075,20 @@ main (int argc, char *argv[])
 	g_type_init ();
 #endif
 
-	load_config ();
+	if (check_config_dir () == 0)
+	{
+		if (load_config () != 0)
+			load_default_config ();
+	} else
+	{
+		/* this is probably the first run */
+		load_default_config ();
+		make_config_dirs (); /* FIXME: if this fail display an error (?) */
+		make_dcc_dirs ();
+	}
 
-#ifdef WIN32
 	/* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */
-	set_locale();
-#endif
+	set_locale ();
 
 #ifdef SOCKS
 	SOCKSinit (argv[0]);