Use g_access instead of g_file_test consistently
This commit is contained in:
parent
b8e6084401
commit
045cc81b45
7 changed files with 27 additions and 13 deletions
|
@ -90,7 +90,7 @@ adblock_download_notify_status_cb (WebKitDownload* download,
|
||||||
GParamSpec* pspec,
|
GParamSpec* pspec,
|
||||||
gchar* path)
|
gchar* path)
|
||||||
{
|
{
|
||||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
if (g_access (path, F_OK) != 0)
|
||||||
return;
|
return;
|
||||||
adblock_parse_file (path);
|
adblock_parse_file (path);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
@ -118,7 +118,7 @@ adblock_reload_rules (MidoriExtension* extension)
|
||||||
gchar* filename = g_compute_checksum_for_string (G_CHECKSUM_MD5,
|
gchar* filename = g_compute_checksum_for_string (G_CHECKSUM_MD5,
|
||||||
filters[i - 1], -1);
|
filters[i - 1], -1);
|
||||||
gchar* path = g_build_filename (folder, filename, NULL);
|
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;
|
WebKitNetworkRequest* request;
|
||||||
WebKitDownload* download;
|
WebKitDownload* download;
|
||||||
|
|
|
@ -13,8 +13,13 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "katze-net.h"
|
#include "katze-net.h"
|
||||||
|
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <libsoup/soup.h>
|
#include <libsoup/soup.h>
|
||||||
#include <webkit/webkit.h>
|
#include <webkit/webkit.h>
|
||||||
|
|
||||||
|
@ -254,7 +259,7 @@ katze_net_local_cb (KatzeNetPriv* priv)
|
||||||
request = priv->request;
|
request = priv->request;
|
||||||
filename = g_filename_from_uri (request->uri, NULL, NULL);
|
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;
|
request->status = KATZE_NET_NOT_FOUND;
|
||||||
if (priv->status_cb)
|
if (priv->status_cb)
|
||||||
|
|
|
@ -1440,7 +1440,7 @@ midori_load_session (gpointer data)
|
||||||
|
|
||||||
browser = midori_app_create_browser (app);
|
browser = midori_app_create_browser (app);
|
||||||
config_file = build_config_filename ("session.old.xbel");
|
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);
|
GtkActionGroup* action_group = midori_browser_get_action_group (browser);
|
||||||
GtkAction* action = gtk_action_group_get_action (action_group, "LastSession");
|
GtkAction* action = gtk_action_group_get_action (action_group, "LastSession");
|
||||||
|
@ -1876,7 +1876,7 @@ main (int argc,
|
||||||
error = NULL;
|
error = NULL;
|
||||||
settings = settings_new_from_file (config_file, &extensions);
|
settings = settings_new_from_file (config_file, &extensions);
|
||||||
katze_assign (config_file, build_config_filename ("accels"));
|
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"));
|
katze_assign (config_file, sokoke_find_config_filename (NULL, "accels"));
|
||||||
gtk_accel_map_load (config_file);
|
gtk_accel_map_load (config_file);
|
||||||
katze_assign (config_file, build_config_filename ("search"));
|
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. */
|
and deleted during normal runtime, but persists in case of a crash. */
|
||||||
katze_assign (config_file, build_config_filename ("running"));
|
katze_assign (config_file, build_config_filename ("running"));
|
||||||
if (katze_object_get_boolean (settings, "show-crash-dialog")
|
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);
|
GtkWidget* dialog = midori_create_diagnostic_dialog (settings, _session);
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define katze_str_equal(str1, str2) !strcmp (str1, str2)
|
#define katze_str_equal(str1, str2) !strcmp (str1, str2)
|
||||||
|
|
||||||
static void
|
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 (filename != NULL, FALSE);
|
||||||
g_return_val_if_fail (!error || !*error, 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 */
|
/* File doesn't exist */
|
||||||
if (error)
|
if (error)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "sokoke.h"
|
#include "sokoke.h"
|
||||||
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <string.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),
|
body_fname = g_build_filename (sokoke_set_config_dir (NULL),
|
||||||
"speeddial.json", 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* filename = g_build_filename ("midori", "res", "speeddial.json", NULL);
|
||||||
gchar* filepath = sokoke_find_data_filename (filename);
|
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 (),
|
gchar* path = g_build_filename (g_get_home_dir (),
|
||||||
bookmark_clients[i].path, NULL);
|
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,
|
gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
|
||||||
0, _(bookmark_clients[i].name), 1, bookmark_clients[i].icon,
|
0, _(bookmark_clients[i].name), 1, bookmark_clients[i].icon,
|
||||||
2, path, 3, icon_width, -1);
|
2, path, 3, icon_width, -1);
|
||||||
|
@ -4648,7 +4649,7 @@ _action_help_link_activate (GtkAction* action,
|
||||||
{
|
{
|
||||||
#ifdef DOCDIR
|
#ifdef DOCDIR
|
||||||
uri = "file://" DOCDIR "/midori/user/midori.html";
|
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
|
#endif
|
||||||
uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
|
uri = "error:nodocs " DOCDIR "/midori/user/midori.html";
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <webkit/webkit.h>
|
#include <webkit/webkit.h>
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is unstable API, so we need to declare it */
|
/* This is unstable API, so we need to declare it */
|
||||||
gchar*
|
gchar*
|
||||||
webkit_web_view_get_selected_text (WebKitWebView* web_view);
|
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),
|
body_fname = g_build_filename (sokoke_set_config_dir (NULL),
|
||||||
"speeddial.json", 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",
|
if (g_file_get_contents (MDATADIR "/midori/res/speeddial.json",
|
||||||
&speed_dial_body, NULL, NULL))
|
&speed_dial_body, NULL, NULL))
|
||||||
|
|
|
@ -1287,7 +1287,7 @@ sokoke_find_config_filename (const gchar* folder,
|
||||||
while ((config_dir = config_dirs[i++]))
|
while ((config_dir = config_dirs[i++]))
|
||||||
{
|
{
|
||||||
gchar* path = g_build_filename (config_dir, PACKAGE_NAME, folder, filename, NULL);
|
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;
|
return path;
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
@ -1313,7 +1313,7 @@ sokoke_find_data_filename (const gchar* filename)
|
||||||
while ((data_dir = data_dirs[i++]))
|
while ((data_dir = data_dirs[i++]))
|
||||||
{
|
{
|
||||||
gchar* path = g_build_filename (data_dir, filename, NULL);
|
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;
|
return path;
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue