aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-file-helpers.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-24 05:35:18 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-24 05:35:18 +0800
commit3c094d65a71666e40b14cb8edc8bbb255b09b8cf (patch)
treeded1435b5ff1d320f37c834e883defa43ba5741e /lib/ephy-file-helpers.c
parentb32d62815640aabd7e2b8f88ee8577ad02c7796f (diff)
downloadgsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.gz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.bz2
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.lz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.xz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.zst
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.zip
Add a GError** to ephy_file_helpers_init and ephy_ensure_dir_exists, so we
2006-01-23 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/MozDownload.cpp: * lib/ephy-file-helpers.c: (ephy_file_helpers_init), (ephy_ensure_dir_exists): * lib/ephy-file-helpers.h: Add a GError** to ephy_file_helpers_init and ephy_ensure_dir_exists, so we can show the error to the user in main(). * src/ephy-dbus.c: (ephy_dbus_connect_to_session_bus_cb), (ephy_dbus_connect_to_system_bus_cb), (session_filter_func), (system_filter_func), (ephy_dbus_connect_to_system_bus), (ephy_dbus_connect_to_session_bus), (ephy_dbus_shutdown), (ephy_dbus_finalize), (ephy_dbus_get_type), (ephy_dbus_get_default), (ephy_dbus_get_bus), (ephy_dbus_get_proxy), (_ephy_dbus_startup), (_ephy_dbus_release), (_ephy_dbus_is_name_owner): * src/ephy-dbus.h: Refactored. Propagate errors to callers via GError**, and change lifecycle to the app lifetime. * src/ephy-lockdown.c: (ephy_lockdown_init), (ephy_lockdown_finalize): Move gconf notification add/remove for the lockdown key dirs here from main(). * src/ephy-shell.c: (ephy_shell_dispose), (_ephy_shell_create_instance): * src/ephy-shell.h: * src/epiphany.defs: Remove ephy_shell_startup and related stuff. * src/ephy-main.c: (handle_url), (handle_email), (shell_weak_notify), (dbus_g_proxy_finalized_cb), (save_yourself_cb), (die_cb), (gnome_session_init), (path_from_command_line_arg), (open_urls), (call_dbus_proxy), (show_error_message), (main): Move all startup code to main(), so we can show errors to the user instead of crashing when things go wrong. Part of bug #326807.
Diffstat (limited to 'lib/ephy-file-helpers.c')
-rw-r--r--lib/ephy-file-helpers.c42
1 files changed, 28 insertions, 14 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;