1 --- src/enchant.c 27 Sep 2006 16:26:03 -0000 1.69 2 +++ src/enchant.c 27 Apr 2007 15:25:03 -0000 3 @@ -89,6 +89,28 @@ typedef void (*EnchantPreCon 4 /********************************************************************************/ 5 /********************************************************************************/ 6 7 +static void 8 +_enchant_ensure_private_datadir (void) 9 +{ 10 + /* test if ~/.enchant exists */ 11 + char * home_dir; 12 + 13 + home_dir = enchant_get_user_home_dir (); 14 + if (home_dir) { 15 + char * enchant_path; 16 + 17 + enchant_path = g_build_filename (home_dir, ENCHANT_USER_PATH_EXTENSION, NULL); 18 + if (enchant_path && !g_file_test (enchant_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) 19 + { 20 + (void)g_remove (enchant_path); 21 + g_mkdir (enchant_path, 0700); 22 + } 23 + 24 + g_free (enchant_path); 25 + g_free (home_dir); 26 + } 27 +} 28 + 29 static char * 30 enchant_get_module_dir (void) 31 { 32 @@ -303,6 +325,7 @@ enchant_session_new (EnchantProvider *pr 33 home_dir = enchant_get_user_home_dir (); 34 if (home_dir) 35 { 36 + _enchant_ensure_private_datadir (); 37 filename = g_strdup_printf ("%s.dic", lang); 38 dic = g_build_filename (home_dir, 39 ENCHANT_USER_PATH_EXTENSION, 40 @@ -311,7 +334,7 @@ enchant_session_new (EnchantProvider *pr 41 g_free (filename); 42 g_free (home_dir); 43 } 44 - 45 + 46 session = enchant_session_new_with_pwl (provider, dic, lang, FALSE); 47 48 if (dic) 49 Index: src/pwl.c 50 =================================================================== 51 RCS file: /cvsroot/enchant/src/pwl.c,v 52 retrieving revision 1.1 53 diff -u -p -r1.1 pwl.c 54 --- src/pwl.c 6 May 2006 16:02:16 -0000 1.1 55 +++ src/pwl.c 27 Apr 2007 15:25:04 -0000 56 @@ -219,16 +219,18 @@ EnchantPWL* enchant_pwl_init(void) 57 EnchantPWL* enchant_pwl_init_with_file(const char * file) 58 { 59 FILE *f; 60 + EnchantPWL *pwl; 61 62 + g_return_val_if_fail (file != NULL, NULL); 63 + 64 + pwl = enchant_pwl_init(); 65 + pwl->filename = g_strdup(file); 66 + 67 f = fopen (file, "r"); 68 if (f) 69 { 70 - EnchantPWL *pwl; 71 char line[BUFSIZ]; 72 73 - pwl = enchant_pwl_init(); 74 - pwl->filename = g_strdup(file); 75 - 76 enchant_lock_file (f); 77 78 while (NULL != (fgets (line, sizeof (line), f))) 79 @@ -242,11 +244,9 @@ EnchantPWL* enchant_pwl_init_with_file(c 80 81 enchant_unlock_file (f); 82 fclose (f); 83 - 84 - return pwl; 85 } 86 87 - return NULL; 88 + return pwl; 89 } 90 91 void enchant_pwl_free(EnchantPWL *pwl) 92