diff options
author | Christian Persch <chpe@src.gnome.org> | 2009-01-26 18:29:31 (GMT) |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2009-01-26 18:29:31 (GMT) |
commit | 84c2106c83ce1eb1b0012e9714ef15875e202e72 (patch) | |
tree | bb20dd741519c3b73b860219d14a6b69a28ab8c6 /libdocument/ev-file-helpers.c | |
parent | d8e0f342c454da540242925c83a218d6c24be3dd (diff) |
Move ev_dot_dir() from libdocument to shell, since it shouldn't be public
* libdocument/ev-file-helpers.c: (ev_dir_ensure_exists),
(ev_tmp_dir), (ev_file_helpers_init), (ev_file_helpers_shutdown):
* libdocument/ev-file-helpers.h:
* shell/ev-application.c: (ev_application_shutdown),
(ev_application_init), (ev_application_screensaver_disable),
(ev_application_save_print_settings),
(ev_application_set_page_setup):
* shell/ev-application.h:
* shell/ev-metadata-manager.c: (load_values),
(ev_metadata_manager_save): Move ev_dot_dir() from libdocument to
shell, since it shouldn't be public API. Bug #569120.
* libdocument/ev-file-helpers.c: (ev_tmp_filename): Use
g_get_prgname() instead of hardcoding "evince" for the tmpdir name.
svn path=/trunk/; revision=3383
Diffstat (limited to 'libdocument/ev-file-helpers.c')
-rw-r--r-- | libdocument/ev-file-helpers.c | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c index b2451ac..9c65aa5 100644 --- a/libdocument/ev-file-helpers.c +++ b/libdocument/ev-file-helpers.c @@ -36,59 +36,38 @@ #include "ev-file-helpers.h" -static gchar *dot_dir = NULL; static gchar *tmp_dir = NULL; static gint count = 0; -static gboolean -ensure_dir_exists (const char *dir) +gboolean +ev_dir_ensure_exists (const gchar *dir, + int mode) { - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) - return TRUE; - - if (g_mkdir_with_parents (dir, 488) == 0) + if (g_mkdir_with_parents (dir, mode) == 0) return TRUE; if (errno == EEXIST) return g_file_test (dir, G_FILE_TEST_IS_DIR); - g_warning ("Failed to create directory %s: %s", dir, strerror (errno)); + g_warning ("Failed to create directory %s: %s", dir, g_strerror (errno)); return FALSE; } const gchar * -ev_dot_dir (void) -{ - if (dot_dir == NULL) { - gboolean exists; - - dot_dir = g_build_filename (g_get_home_dir (), - ".gnome2", - "evince", - NULL); - - exists = ensure_dir_exists (dot_dir); - if (!exists) - exit (1); - } - - return dot_dir; -} - -const gchar * ev_tmp_dir (void) { if (tmp_dir == NULL) { gboolean exists; - gchar *dirname; + gchar *dirname, *prgname; - dirname = g_strdup_printf ("evince-%u", getpid ()); + prgname = g_get_prgname (); + dirname = g_strdup_printf ("%s-%u", prgname ? prgname : "unknown", getpid ()); tmp_dir = g_build_filename (g_get_tmp_dir (), dirname, NULL); g_free (dirname); - exists = ensure_dir_exists (tmp_dir); + exists = ev_dir_ensure_exists (tmp_dir, 0700); g_assert (exists); } @@ -107,9 +86,6 @@ ev_file_helpers_shutdown (void) g_rmdir (tmp_dir); g_free (tmp_dir); - g_free (dot_dir); - - dot_dir = NULL; tmp_dir = NULL; } |