svnno****@sourc*****
svnno****@sourc*****
Tue Mar 27 14:29:19 JST 2007
Revision: 3046 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3046 Author: kous Date: 2007-03-27 14:29:18 +0900 (Tue, 27 Mar 2007) Log Message: ----------- * module/embed/gecko/kz-mozwrapper.cpp, src/actions/kz-actions.c: use KZ_GET_CLIPS_DIR. * src/kazehakase.h, src/kz-app.[ch]: added favicon, smartbookmark_history, form_data, clips directory. * src/kz-app.c (ensure_directories): renamed from prepare_dir(). * src/utils/glib-utils.[ch] (g_mkdir_with_parents): added. * src/utils/utils.[ch] (make_dir): removed. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp kazehakase/trunk/src/actions/kz-actions.c kazehakase/trunk/src/kazehakase.h kazehakase/trunk/src/kz-app.c kazehakase/trunk/src/kz-app.h kazehakase/trunk/src/kz-favicon.c kazehakase/trunk/src/utils/glib-utils.c kazehakase/trunk/src/utils/glib-utils.h kazehakase/trunk/src/utils/utils.c kazehakase/trunk/src/utils/utils.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/ChangeLog 2007-03-27 05:29:18 UTC (rev 3046) @@ -1,3 +1,17 @@ +2007-03-27 Kouhei Sutou <kou****@cozmi*****> + + * module/embed/gecko/kz-mozwrapper.cpp, + src/actions/kz-actions.c: use KZ_GET_CLIPS_DIR. + + * src/kazehakase.h, src/kz-app.[ch]: added favicon, + smartbookmark_history, form_data, clips directory. + + * src/kz-app.c (ensure_directories): renamed from prepare_dir(). + + * src/utils/glib-utils.[ch] (g_mkdir_with_parents): added. + + * src/utils/utils.[ch] (make_dir): removed. + 2007-03-27 Hiroyuki Ikezoe <poinc****@ikezo*****> * module/embed/gecko/MozillaPrivate.cpp: Use egg-pifbux-thumbnail. Modified: kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp 2007-03-27 05:29:18 UTC (rev 3046) @@ -29,6 +29,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include "kazehakase.h" #include "kz-mozwrapper.h" #include <gtkmozembed_internal.h> @@ -1319,10 +1320,9 @@ NS_CStringGetData(URI, &uri); gchar *filename = create_filename_from_uri(uri); - dir = g_build_filename(g_get_home_dir(), - "."PACKAGE, + dir = g_build_filename(KZ_GET_CLIPS_DIR, storedir, - type, /* images or css */ + type, /* images or css */ filename, NULL); Modified: kazehakase/trunk/src/actions/kz-actions.c =================================================================== --- kazehakase/trunk/src/actions/kz-actions.c 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/actions/kz-actions.c 2007-03-27 05:29:18 UTC (rev 3046) @@ -1248,7 +1248,8 @@ struct tm *date = NULL; time_t t; gchar time_string[20]; - gchar *filename, *htmlname = NULL, *dirname, *link, *name; + gchar *filename, *htmlname = NULL, *link, *name; + gchar *dir_name, *clip_dir_name; gchar *pos, *full_htmlname; GIOChannel *io; @@ -1286,15 +1287,13 @@ full_htmlname = g_strconcat(htmlname, ".html", NULL); - dirname = g_strconcat("clips"G_DIR_SEPARATOR_S, htmlname, time_string, NULL); - make_dir(dirname); + dir_name = g_strconcat(htmlname, time_string, NULL); + clip_dir_name = g_build_filename(KZ_GET_CLIPS_DIR, dir_name, NULL); + g_mkdir_with_parents(clip_dir_name, 0700); - source = kz_embed_get_html_with_contents(KZ_EMBED(embed), - dirname); + source = kz_embed_get_html_with_contents(KZ_EMBED(embed), dir_name); - filename = g_build_filename(g_get_home_dir(), - "."PACKAGE, - dirname, + filename = g_build_filename(clip_dir_name, full_htmlname, NULL); @@ -1319,7 +1318,8 @@ g_free(link); g_free(filename); - g_free(dirname); + g_free(dir_name); + g_free(clip_dir_name); g_free(htmlname); g_free(full_htmlname); } Modified: kazehakase/trunk/src/kazehakase.h =================================================================== --- kazehakase/trunk/src/kazehakase.h 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/kazehakase.h 2007-03-27 05:29:18 UTC (rev 3046) @@ -72,6 +72,10 @@ #define KZ_GET_HISTORY_DIR kz_app_get_history_dir(kz_app) #define KZ_GET_HISTORY_TIME_STAMP kz_app_get_history_time_stamp(kz_app) #define KZ_GET_POPUP_DIR kz_app_get_popup_dir(kz_app) +#define KZ_GET_FAVICON_DIR kz_app_get_favicon_dir(kz_app) +#define KZ_GET_SMARTBOOKMARK_HISTORY_DIR kz_app_get_smartbookmark_history_dir(kz_app) +#define KZ_GET_FORM_DATA_DIR kz_app_get_form_data_dir(kz_app) +#define KZ_GET_CLIPS_DIR kz_app_get_clips_dir(kz_app) #define KZ_GET_SYSTEM_DATA_DIR kz_app_get_system_data_dir(kz_app) #define KZ_GET_SYSTEM_RUBY_EXT_DIR kz_app_get_system_ruby_ext_dir(kz_app) Modified: kazehakase/trunk/src/kz-app.c =================================================================== --- kazehakase/trunk/src/kz-app.c 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/kz-app.c 2007-03-27 05:29:18 UTC (rev 3046) @@ -43,6 +43,7 @@ # include <fcntl.h> #endif /* HAVE_LIBSM */ +#include <glib/gstdio.h> #include <glib/gi18n.h> #include "kazehakase.h" #include "kz-actions-tab.h" @@ -85,6 +86,10 @@ gchar *history_dir; gchar *history_time_stamp; gchar *popup_dir; + gchar *favicon_dir; + gchar *smartbookmark_history_dir; + gchar *form_data_dir; + gchar *clips_dir; gchar *system_data_dir; gchar *system_ruby_ext_dir; }; @@ -220,19 +225,16 @@ static void -prepare_dir (void) +ensure_directories (KzApp *app) { - /* for favicon */ - make_dir("favicon"); + KzAppPrivate *priv = KZ_APP_GET_PRIVATE(app); - /* for popup */ - make_dir("popup"); - - /* for smart bookmark input history */ - make_dir("smartbookmark_history"); - - /* for storing form data */ - make_dir("form_data"); + g_mkdir_with_parents(priv->history_dir, 0700); + g_mkdir_with_parents(priv->favicon_dir, 0700); + g_mkdir_with_parents(priv->popup_dir, 0700); + g_mkdir_with_parents(priv->smartbookmark_history_dir, 0700); + g_mkdir_with_parents(priv->form_data_dir, 0700); + g_mkdir_with_parents(priv->clips_dir, 0700); } static void @@ -250,9 +252,17 @@ "time-stamp", NULL); priv->popup_dir = g_build_filename(priv->user_dir, "popup", NULL); + priv->favicon_dir = g_build_filename(priv->user_dir, "favicon", NULL); + priv->smartbookmark_history_dir = + g_build_filename(priv->user_dir, "smartbookmark_history", NULL); + priv->form_data_dir = + g_build_filename(priv->user_dir, "form_data", NULL); + priv->clips_dir = g_build_filename(priv->user_dir, "clips", NULL); priv->system_data_dir = g_strdup(KZ_DATADIR); priv->system_ruby_ext_dir = g_strdup(KZ_RUBY_EXTDIR); + + ensure_directories(app); } static void @@ -264,6 +274,10 @@ g_free(priv->history_dir); g_free(priv->history_time_stamp); g_free(priv->popup_dir); + g_free(priv->favicon_dir); + g_free(priv->smartbookmark_history_dir); + g_free(priv->form_data_dir); + g_free(priv->clips_dir); g_free(priv->system_data_dir); g_free(priv->system_ruby_ext_dir); @@ -271,6 +285,10 @@ priv->history_dir = NULL; priv->history_time_stamp = NULL; priv->popup_dir = NULL; + priv->favicon_dir = NULL; + priv->smartbookmark_history_dir = NULL; + priv->form_data_dir = NULL; + priv->clips_dir = NULL; priv->system_data_dir = NULL; priv->system_ruby_ext_dir = NULL; } @@ -288,6 +306,10 @@ DEFINE_PATH_GETTER(history_dir) DEFINE_PATH_GETTER(history_time_stamp) DEFINE_PATH_GETTER(popup_dir) +DEFINE_PATH_GETTER(favicon_dir) +DEFINE_PATH_GETTER(smartbookmark_history_dir) +DEFINE_PATH_GETTER(form_data_dir) +DEFINE_PATH_GETTER(clips_dir) DEFINE_PATH_GETTER(system_data_dir) DEFINE_PATH_GETTER(system_ruby_ext_dir) @@ -379,9 +401,6 @@ kz_icons_init(); - /* make dirs */ - prepare_dir(); - #ifdef USE_SSL /* initialize gnutls. this function should be called once. */ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); Modified: kazehakase/trunk/src/kz-app.h =================================================================== --- kazehakase/trunk/src/kz-app.h 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/kz-app.h 2007-03-27 05:29:18 UTC (rev 3046) @@ -59,6 +59,10 @@ const gchar *kz_app_get_history_dir (KzApp *app); const gchar *kz_app_get_history_time_stamp (KzApp *app); const gchar *kz_app_get_popup_dir (KzApp *app); +const gchar *kz_app_get_favicon_dir (KzApp *app); +const gchar *kz_app_get_smartbookmark_history_dir (KzApp *app); +const gchar *kz_app_get_form_data_dir (KzApp *app); +const gchar *kz_app_get_clips_dir (KzApp *app); const gchar *kz_app_get_system_data_dir (KzApp *app); const gchar *kz_app_get_system_ruby_ext_dir (KzApp *app); Modified: kazehakase/trunk/src/kz-favicon.c =================================================================== --- kazehakase/trunk/src/kz-favicon.c 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/kz-favicon.c 2007-03-27 05:29:18 UTC (rev 3046) @@ -24,6 +24,7 @@ #include <string.h> +#include "kazehakase.h" #include "kz-favicon.h" #include "kz-profile.h" #include "kz-downloader.h" @@ -395,9 +396,7 @@ if (!uri) return; favicon_filename = create_filename_from_uri(uri); - favicon_file_location = g_build_filename(g_get_home_dir(), - "."PACKAGE, - "favicon", + favicon_file_location = g_build_filename(KZ_GET_FAVICON_DIR, favicon_filename, NULL); g_free(favicon_filename); Modified: kazehakase/trunk/src/utils/glib-utils.c =================================================================== --- kazehakase/trunk/src/utils/glib-utils.c 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/utils/glib-utils.c 2007-03-27 05:29:18 UTC (rev 3046) @@ -26,6 +26,81 @@ #include "glib-utils.h" +#if !GLIB_CHECK_VERSION(2, 8, 0) +/** + * g_mkdir_with_parents: + * @pathname: a pathname in the GLib file name encoding + * @mode: permissions to use for newly created directories + * + * Create a directory if it doesn't already exist. Create intermediate + * parent directories as needed, too. + * + * Returns: 0 if the directory already exists, or was successfully + * created. Returns -1 if an error occurred, with errno set. + * + * Since: 2.8 + */ +int +g_mkdir_with_parents (const gchar *pathname, + int mode) +{ + gchar *fn, *p; + + if (pathname == NULL || *pathname == '\0') + { + errno = EINVAL; + return -1; + } + + fn = g_strdup (pathname); + + if (g_path_is_absolute (fn)) + p = (gchar *) g_path_skip_root (fn); + else + p = fn; + + do + { + while (*p && !G_IS_DIR_SEPARATOR (*p)) + p++; + + if (!*p) + p = NULL; + else + *p = '\0'; + + if (!g_file_test (fn, G_FILE_TEST_EXISTS)) + { + if (g_mkdir (fn, mode) == -1) + { + int errno_save = errno; + g_free (fn); + errno = errno_save; + return -1; + } + } + else if (!g_file_test (fn, G_FILE_TEST_IS_DIR)) + { + g_free (fn); + errno = ENOTDIR; + return -1; + } + if (p) + { + *p++ = G_DIR_SEPARATOR; + while (*p && G_IS_DIR_SEPARATOR (*p)) + p++; + } + } + while (p); + + g_free (fn); + + return 0; +} +#endif + + #if !GLIB_CHECK_VERSION(2, 13, 0) #include "gscripttable.h" Modified: kazehakase/trunk/src/utils/glib-utils.h =================================================================== --- kazehakase/trunk/src/utils/glib-utils.h 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/utils/glib-utils.h 2007-03-27 05:29:18 UTC (rev 3046) @@ -29,6 +29,10 @@ #define g_strlen(s) ((s)!=NULL?strlen(s):0) #define g_strcmp(s1,s2) ((s1)!=NULL && (s2)!=NULL?strcmp(s1,s2):0) +#if !GLIB_CHECK_VERSION(2, 8, 0) +int g_mkdir_with_parents (const gchar *pathname, int mode); +#endif + #if !GLIB_CHECK_VERSION(2, 10, 0) #define g_object_ref_sink(o) gtk_object_sink(GTK_OBJECT(o)) #endif Modified: kazehakase/trunk/src/utils/utils.c =================================================================== --- kazehakase/trunk/src/utils/utils.c 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/utils/utils.c 2007-03-27 05:29:18 UTC (rev 3046) @@ -43,38 +43,6 @@ #define TIME_STAMP_FORMAT "%ld,%s\n" -void -make_dir (const gchar *dirname) -{ - gint i = 0, ii = 0, ret; - gchar *temp, *temp2; - - temp = g_build_filename(g_get_home_dir(), "."PACKAGE, dirname, NULL); - temp2 = g_alloca(strlen(temp) + 1); - - while (temp[i]) - { - temp2[ii++] = temp[i]; - temp2[ii] = '\0'; - if ((temp[i + 1] == '/' || !temp[i + 1]) && - !g_file_test(temp2, G_FILE_TEST_IS_DIR)) - { - ret = g_mkdir(temp2, 0711); - -#if 0 /* show dialog? */ - if (ret != 0) - { - perror("Faild to create directory");; - } -#endif - } - i++; - } - - g_free(temp); -} - - gboolean key_seems_sequential (const gchar *key, const gchar *prefix) { Modified: kazehakase/trunk/src/utils/utils.h =================================================================== --- kazehakase/trunk/src/utils/utils.h 2007-03-27 05:26:12 UTC (rev 3045) +++ kazehakase/trunk/src/utils/utils.h 2007-03-27 05:29:18 UTC (rev 3046) @@ -28,7 +28,6 @@ G_BEGIN_DECLS -void make_dir (const gchar *dirname); gboolean key_seems_sequential (const gchar *key, const gchar *prefix); gchar *remove_tag (const gchar *string, gsize len);