diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-file-helpers.c | 42 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 8 |
2 files changed, 34 insertions, 16 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index b8acb26fb..c9c62d043 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -63,6 +63,8 @@ static char *dot_dir = NULL; static char *tmp_dir = NULL; static GList *del_on_exit = NULL; +GQuark ephy_file_helpers_error_quark; + const char * ephy_file_tmp_dir (void) { @@ -260,8 +262,8 @@ ephy_dot_dir (void) return dot_dir; } -void -ephy_file_helpers_init (void) +gboolean +ephy_file_helpers_init (GError **error) { const char *uuid; @@ -276,10 +278,14 @@ ephy_file_helpers_init (void) /* Put marker in env */ g_setenv (EPHY_UUID_ENVVAR, EPHY_UUID, TRUE); + ephy_file_helpers_error_quark = g_quark_from_static_string ("ephy-file-helpers-error"); + files = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_free); + + return ephy_ensure_dir_exists (ephy_dot_dir (), error); } static void @@ -321,21 +327,29 @@ ephy_file_helpers_shutdown (void) } gboolean -ephy_ensure_dir_exists (const char *dir) +ephy_ensure_dir_exists (const char *dir, + GError **error) { - if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE) + if (g_file_test (dir, G_FILE_TEST_EXISTS) && + !g_file_test (dir, G_FILE_TEST_IS_DIR)) { - if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE) - { - g_warning (_("\"%s\" exists, please move it out of the way."), dir); - return FALSE; - } + g_set_error (error, + EPHY_FILE_HELPERS_ERROR_QUARK, + 0, + _("ā%sā exists, please move it out of the way."), + dir); + return FALSE; + } - if (mkdir (dir, 488) != 0) - { - g_warning (_("Failed to create directory \"%s\"."), dir); - return FALSE; - } + if (!g_file_test (dir, G_FILE_TEST_EXISTS) && + mkdir (dir, 488) != 0) + { + g_set_error (error, + EPHY_FILE_HELPERS_ERROR_QUARK, + 0, + _("Failed to create directory ā%sā."), + dir); + return FALSE; } return TRUE; diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 15a1ff825..189cc17e2 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -27,6 +27,9 @@ #include <libgnomevfs/gnome-vfs-mime-handlers.h> #include <libgnomevfs/gnome-vfs-ops.h> +extern GQuark ephy_file_helpers_error_quark; +#define EPHY_FILE_HELPERS_ERROR_QUARK (ephy_file_helpers_error_quark) + G_BEGIN_DECLS typedef enum @@ -44,7 +47,7 @@ const char *ephy_file (const char *filename); const char *ephy_dot_dir (void); -void ephy_file_helpers_init (void); +gboolean ephy_file_helpers_init (GError **error); void ephy_file_helpers_shutdown (void); @@ -59,7 +62,8 @@ const char *ephy_file_tmp_dir (void); char *ephy_file_tmp_filename (const char *base, const char *extension); -gboolean ephy_ensure_dir_exists (const char *dir); +gboolean ephy_ensure_dir_exists (const char *dir, + GError **); GSList *ephy_file_find (const char *path, const char *fname, |