From 045cc81b45cd3a109c226d36962bd2ffa8b99652 Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Sat, 19 Dec 2009 10:39:24 +0100 Subject: [PATCH] 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 d254de9f..18bd1b0a 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 83ef0519..5374478a 100644 --- a/katze/katze-net.c +++ b/katze/katze-net.c @@ -13,8 +13,13 @@ #include #endif +#if HAVE_UNISTD_H + #include +#endif + #include "katze-net.h" +#include #include #include @@ -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 77c0cd52..b05a314d 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 1adfd2bf..3e725462 100644 --- a/midori/midori-array.c +++ b/midori/midori-array.c @@ -23,6 +23,10 @@ #include #endif +#if HAVE_UNISTD_H + #include +#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 5e72aec7..cac0fab1 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -31,6 +31,7 @@ #include "sokoke.h" #include +#include #include #include #include @@ -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 31876a2b..9cfde83c 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -30,6 +30,10 @@ #include #include +#if HAVE_UNISTD_H + #include +#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 932d8e6b..d6377ac1 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); }