[Xfce4-commits] <midori:master> Use g_access instead of g_file_test consistently

Christian Dywan noreply at xfce.org
Sat Dec 19 11:30:01 CET 2009


Updating branch refs/heads/master
         to 045cc81b45cd3a109c226d36962bd2ffa8b99652 (commit)
       from b8e60844015fee0f3bf85bb68805fc512611df0e (commit)

commit 045cc81b45cd3a109c226d36962bd2ffa8b99652
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Sat Dec 19 10:39:24 2009 +0100

    Use g_access instead of g_file_test consistently

 extensions/adblock.c    |    4 ++--
 katze/katze-net.c       |    7 ++++++-
 midori/main.c           |    6 +++---
 midori/midori-array.c   |    6 +++++-
 midori/midori-browser.c |    7 ++++---
 midori/midori-view.c    |    6 +++++-
 midori/sokoke.c         |    4 ++--
 7 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index d254de9..18bd1b0 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -90,7 +90,7 @@ adblock_download_notify_status_cb (WebKitDownload* download,
                                    GParamSpec*     pspec,
                                    gchar*          path)
 {
-    if (!g_file_test (path, G_FILE_TEST_EXISTS))
+    if (g_access (path, F_OK) != 0)
        return;
     adblock_parse_file (path);
     g_free (path);
@@ -118,7 +118,7 @@ adblock_reload_rules (MidoriExtension* extension)
         gchar* filename = g_compute_checksum_for_string (G_CHECKSUM_MD5,
                                                          filters[i - 1], -1);
         gchar* path = g_build_filename (folder, filename, NULL);
-        if (!g_file_test (path, G_FILE_TEST_EXISTS))
+        if (g_access (path, F_OK) != 0)
         {
             WebKitNetworkRequest* request;
             WebKitDownload* download;
diff --git a/katze/katze-net.c b/katze/katze-net.c
index 83ef051..5374478 100644
--- a/katze/katze-net.c
+++ b/katze/katze-net.c
@@ -13,8 +13,13 @@
     #include <config.h>
 #endif
 
+#if HAVE_UNISTD_H
+    #include <unistd.h>
+#endif
+
 #include "katze-net.h"
 
+#include <glib/gstdio.h>
 #include <libsoup/soup.h>
 #include <webkit/webkit.h>
 
@@ -254,7 +259,7 @@ katze_net_local_cb (KatzeNetPriv* priv)
     request = priv->request;
     filename = g_filename_from_uri (request->uri, NULL, NULL);
 
-    if (!filename || !g_file_test (filename, G_FILE_TEST_EXISTS))
+    if (!filename || g_access (filename, F_OK) != 0)
     {
         request->status = KATZE_NET_NOT_FOUND;
         if (priv->status_cb)
diff --git a/midori/main.c b/midori/main.c
index 77c0cd5..b05a314 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1440,7 +1440,7 @@ midori_load_session (gpointer data)
 
     browser = midori_app_create_browser (app);
     config_file = build_config_filename ("session.old.xbel");
-    if (g_file_test (config_file, G_FILE_TEST_EXISTS))
+    if (g_access (config_file, F_OK) == 0)
     {
         GtkActionGroup* action_group = midori_browser_get_action_group (browser);
         GtkAction* action = gtk_action_group_get_action (action_group, "LastSession");
@@ -1876,7 +1876,7 @@ main (int    argc,
     error = NULL;
     settings = settings_new_from_file (config_file, &extensions);
     katze_assign (config_file, build_config_filename ("accels"));
-    if (!g_file_test (config_file, G_FILE_TEST_EXISTS))
+    if (g_access (config_file, F_OK) != 0)
         katze_assign (config_file, sokoke_find_config_filename (NULL, "accels"));
     gtk_accel_map_load (config_file);
     katze_assign (config_file, build_config_filename ("search"));
@@ -2096,7 +2096,7 @@ main (int    argc,
        and deleted during normal runtime, but persists in case of a crash. */
     katze_assign (config_file, build_config_filename ("running"));
     if (katze_object_get_boolean (settings, "show-crash-dialog")
-        && g_file_test (config_file, G_FILE_TEST_EXISTS))
+        && g_access (config_file, F_OK) == 0)
     {
         GtkWidget* dialog = midori_create_diagnostic_dialog (settings, _session);
         gtk_dialog_run (GTK_DIALOG (dialog));
diff --git a/midori/midori-array.c b/midori/midori-array.c
index 1adfd2b..3e72546 100644
--- a/midori/midori-array.c
+++ b/midori/midori-array.c
@@ -23,6 +23,10 @@
     #include <libxml/tree.h>
 #endif
 
+#if HAVE_UNISTD_H
+    #include <unistd.h>
+#endif
+
 #define katze_str_equal(str1, str2) !strcmp (str1, str2)
 
 static void
@@ -416,7 +420,7 @@ midori_array_from_file (KatzeArray*  array,
     g_return_val_if_fail (filename != NULL, FALSE);
     g_return_val_if_fail (!error || !*error, FALSE);
 
-    if (!g_file_test (filename, G_FILE_TEST_EXISTS))
+    if (g_access (filename, F_OK) != 0)
     {
         /* File doesn't exist */
         if (error)
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 5e72aec..cac0fab 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -31,6 +31,7 @@
 #include "sokoke.h"
 
 #include <glib/gi18n.h>
+#include <glib/gstdio.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
 #include <string.h>
@@ -1022,7 +1023,7 @@ midori_browser_speed_dial_get_next_free_slot (void)
     body_fname = g_build_filename (sokoke_set_config_dir (NULL),
                                    "speeddial.json", NULL);
 
-    if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
+    if (g_access (body_fname, F_OK) != 0)
     {
         gchar* filename = g_build_filename ("midori", "res", "speeddial.json", NULL);
         gchar* filepath = sokoke_find_data_filename (filename);
@@ -4232,7 +4233,7 @@ _action_bookmarks_import_activate (GtkAction*     action,
     {
         gchar* path = g_build_filename (g_get_home_dir (),
                                         bookmark_clients[i].path, NULL);
-        if (g_file_test (path, G_FILE_TEST_EXISTS))
+        if (g_access (path, F_OK) == 0)
             gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
                 0, _(bookmark_clients[i].name), 1, bookmark_clients[i].icon,
                 2, path, 3, icon_width, -1);
@@ -4648,7 +4649,7 @@ _action_help_link_activate (GtkAction*     action,
     {
         #ifdef DOCDIR
         uri = "file://" DOCDIR "/midori/user/midori.html";
-        if (!g_file_test (DOCDIR "/midori/user/midori.html", G_FILE_TEST_EXISTS))
+        if (g_access (DOCDIR "/midori/user/midori.html", F_OK) != 0)
         #endif
             uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
     }
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 31876a2..9cfde83 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -30,6 +30,10 @@
 #include <gdk/gdkkeysyms.h>
 #include <webkit/webkit.h>
 
+#if HAVE_UNISTD_H
+    #include <unistd.h>
+#endif
+
 /* This is unstable API, so we need to declare it */
 gchar*
 webkit_web_view_get_selected_text (WebKitWebView* web_view);
@@ -2936,7 +2940,7 @@ midori_view_set_uri (MidoriView*  view,
             body_fname = g_build_filename (sokoke_set_config_dir (NULL),
                                            "speeddial.json", NULL);
 
-            if (!g_file_test (body_fname, G_FILE_TEST_EXISTS))
+            if (g_access (body_fname, F_OK) != 0)
             {
                 if (g_file_get_contents (MDATADIR "/midori/res/speeddial.json",
                                          &speed_dial_body, NULL, NULL))
diff --git a/midori/sokoke.c b/midori/sokoke.c
index 932d8e6..d6377ac 100644
--- a/midori/sokoke.c
+++ b/midori/sokoke.c
@@ -1287,7 +1287,7 @@ sokoke_find_config_filename (const gchar* folder,
     while ((config_dir = config_dirs[i++]))
     {
         gchar* path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
-        if (g_file_test (path, G_FILE_TEST_EXISTS))
+        if (g_access (filename, F_OK) == 0)
             return path;
         g_free (path);
     }
@@ -1313,7 +1313,7 @@ sokoke_find_data_filename (const gchar* filename)
     while ((data_dir = data_dirs[i++]))
     {
         gchar* path = g_build_filename (data_dir, filename, NULL);
-        if (g_file_test (path, G_FILE_TEST_EXISTS))
+        if (g_access (filename, F_OK) == 0)
             return path;
         g_free (path);
     }



More information about the Xfce4-commits mailing list