Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards gvfs-fuse independence #963

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion plugins/export.c
Expand Up @@ -325,7 +325,7 @@ static void on_file_save_dialog_response(GtkDialog *dialog, gint response, gpoin
utf8_filename = utils_get_utf8_from_locale(new_filename);

/* check if file exists and ask whether to overwrite or not */
if (g_file_test(new_filename, G_FILE_TEST_EXISTS))
if (utils_file_exists(new_filename))
{
if (dialogs_show_question(
_("The file '%s' already exists. Do you want to overwrite it?"),
Expand Down
6 changes: 3 additions & 3 deletions plugins/filebrowser.c
Expand Up @@ -230,7 +230,7 @@ static void add_item(const gchar *name)
/* root directory doesn't need separator */
sep = (utils_str_equal(current_dir, "/")) ? "" : G_DIR_SEPARATOR_S;
fname = g_strconcat(current_dir, sep, name, NULL);
dir = g_file_test(fname, G_FILE_TEST_IS_DIR);
dir = utils_file_is_dir(fname);
utf8_fullname = utils_get_utf8_from_locale(fname);
utf8_name = utils_get_utf8_from_locale(name);
g_free(fname);
Expand Down Expand Up @@ -319,7 +319,7 @@ static void refresh(void)
GSList *list, *node;

/* don't clear when the new path doesn't exist */
if (! g_file_test(current_dir, G_FILE_TEST_EXISTS))
if (! utils_file_exists(current_dir))
return;

clear();
Expand Down Expand Up @@ -1188,7 +1188,7 @@ static void save_settings(void)
g_key_file_set_boolean(config, "filebrowser", "fb_set_project_base_path",
fb_set_project_base_path);

if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
if (! utils_file_is_dir(config_dir) && utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
Expand Down
2 changes: 1 addition & 1 deletion plugins/htmlchars.c
Expand Up @@ -360,7 +360,7 @@ static void set_status(gboolean new_status)
g_key_file_set_boolean(config, "general", "replacement_on_typing_active",
plugin_active);

if (!g_file_test(config_dir, G_FILE_TEST_IS_DIR)
if (!utils_file_is_dir(config_dir)
&& utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
Expand Down
6 changes: 3 additions & 3 deletions plugins/saveactions.c
Expand Up @@ -103,8 +103,8 @@ static gboolean backupcopy_set_backup_dir(const gchar *utf8_dir)
tmp = utils_get_locale_from_utf8(utf8_dir);

if (! g_path_is_absolute(tmp) ||
! g_file_test(tmp, G_FILE_TEST_EXISTS) ||
! g_file_test(tmp, G_FILE_TEST_IS_DIR))
! utils_file_exists(tmp) ||
! utils_file_is_dir(tmp))
{
g_free(tmp);
return FALSE;
Expand Down Expand Up @@ -532,7 +532,7 @@ static void configure_response_cb(GtkDialog *dialog, gint response, G_GNUC_UNUSE
}


if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0)
if (! utils_file_is_dir(config_dir) && utils_mkdir(config_dir, TRUE) != 0)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Plugin configuration directory could not be created."));
Expand Down
4 changes: 2 additions & 2 deletions src/build.c
Expand Up @@ -801,8 +801,8 @@ static gchar *prepare_run_cmd(GeanyDocument *doc, gchar **working_dir, guint cmd
working_dir_utf8 = build_replace_placeholder(doc, cmd_working_dir);
*working_dir = utils_get_locale_from_utf8(working_dir_utf8);

if (EMPTY(*working_dir) || ! g_file_test(*working_dir, G_FILE_TEST_EXISTS) ||
! g_file_test(*working_dir, G_FILE_TEST_IS_DIR))
if (EMPTY(*working_dir) || ! utils_file_exists(*working_dir) ||
! utils_file_is_dir(*working_dir))
{
ui_set_statusbar(TRUE, _("Invalid working directory \"%s\""),
!EMPTY(working_dir_utf8) ? working_dir_utf8 : "<NULL>" );
Expand Down
8 changes: 4 additions & 4 deletions src/callbacks.c
Expand Up @@ -1388,7 +1388,7 @@ void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem, gpointer user_d

filename = g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL);

if (! g_file_test(filename, G_FILE_TEST_EXISTS) &&
if (! utils_file_exists(filename) &&
app->project != NULL && !EMPTY(app->project->base_path))
{
/* try the project's base path */
Expand All @@ -1398,15 +1398,15 @@ void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem, gpointer user_d
}
g_free(path);
#ifdef G_OS_UNIX
if (! g_file_test(filename, G_FILE_TEST_EXISTS))
if (! utils_file_exists(filename))
SETPTR(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/local/include", sel, NULL));

if (! g_file_test(filename, G_FILE_TEST_EXISTS))
if (! utils_file_exists(filename))
SETPTR(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/include", sel, NULL));
#endif
}

if (g_file_test(filename, G_FILE_TEST_EXISTS))
if (utils_file_exists(filename))
document_open_file(filename, FALSE, NULL, NULL);
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/dialogs.c
Expand Up @@ -156,7 +156,7 @@ static gboolean open_file_dialog_handle_response(GtkWidget *dialog, gint respons
const gchar *first = filelist->data;

// When there's only one filename it may have been typed manually
if (!filelist->next && !g_file_test(first, G_FILE_TEST_EXISTS))
if (!filelist->next && !utils_file_exists(first))
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("\"%s\" was not found."), first);
ret = FALSE;
Expand Down Expand Up @@ -530,7 +530,7 @@ static gboolean save_as_dialog_handle_response(GtkWidget *dialog, gint response)
utils_beep();
break;
}
if (g_file_test(new_filename, G_FILE_TEST_EXISTS) &&
if (utils_file_exists(new_filename) &&
!dialogs_show_question_full(NULL, NULL, NULL,
_("Overwrite?"),
_("Filename already exists!")))
Expand Down
5 changes: 1 addition & 4 deletions src/document.c
Expand Up @@ -82,9 +82,6 @@
#include <gdk/gdkkeysyms.h>


#define USE_GIO_FILE_OPERATIONS (!file_prefs.use_safe_file_saving && file_prefs.use_gio_unsafe_file_saving)


GeanyFilePrefs file_prefs;


Expand Down Expand Up @@ -593,7 +590,7 @@ static void monitor_file_setup(GeanyDocument *doc)
document_stop_file_monitoring(doc);

locale_filename = utils_get_locale_from_utf8(doc->file_name);
if (locale_filename != NULL && g_file_test(locale_filename, G_FILE_TEST_EXISTS))
if (locale_filename != NULL && utils_file_exists(locale_filename))
{
/* get a file monitor and connect to the 'changed' signal */
GFile *file = g_file_new_for_path(locale_filename);
Expand Down
2 changes: 1 addition & 1 deletion src/editor.c
Expand Up @@ -276,7 +276,7 @@ void editor_snippets_init(void)
userconfigfile = g_build_filename(app->configdir, "snippets.conf", NULL);

/* check for old autocomplete.conf files (backwards compatibility) */
if (! g_file_test(userconfigfile, G_FILE_TEST_IS_REGULAR))
if (! utils_file_is_regular(userconfigfile))
SETPTR(userconfigfile, g_build_filename(app->configdir, "autocomplete.conf", NULL));

/* load the actual config files */
Expand Down
6 changes: 3 additions & 3 deletions src/highlighting.c
Expand Up @@ -513,7 +513,7 @@ static void load_named_styles(GKeyFile *config, GKeyFile *config_home)
path = g_build_path(G_DIR_SEPARATOR_S, app->datadir, GEANY_COLORSCHEMES_SUBDIR, scheme, NULL);
path_home = g_build_path(G_DIR_SEPARATOR_S, app->configdir, GEANY_COLORSCHEMES_SUBDIR, scheme, NULL);

if (g_file_test(path, G_FILE_TEST_EXISTS) || g_file_test(path_home, G_FILE_TEST_EXISTS))
if (utils_file_exists(path) || utils_file_exists(path_home))
{
config = utils_key_file_new(path);
config_home = utils_key_file_new(path_home);
Expand Down Expand Up @@ -1208,13 +1208,13 @@ static void on_color_scheme_changed(GtkTreeSelection *treesel, gpointer dummy)

/* fname is just the basename from the menu item, so prepend the custom files path */
path = g_build_path(G_DIR_SEPARATOR_S, app->configdir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL);
if (!g_file_test(path, G_FILE_TEST_EXISTS))
if (!utils_file_exists(path))
{
/* try the system path */
g_free(path);
path = g_build_path(G_DIR_SEPARATOR_S, app->datadir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL);
}
if (g_file_test(path, G_FILE_TEST_EXISTS))
if (utils_file_exists(path))
{
SETPTR(editor_prefs.color_scheme, fname);
fname = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/keybindings.c
Expand Up @@ -781,7 +781,7 @@ static void load_user_kb(void)
GKeyFile *config = g_key_file_new();

/* backwards compatibility with Geany 0.21 defaults */
if (!g_file_test(configfile, G_FILE_TEST_EXISTS))
if (!utils_file_exists(configfile))
{
gchar *geanyconf = g_build_filename(app->configdir, "geany.conf", NULL);
const gchar data[] = "[Bindings]\n"
Expand All @@ -792,7 +792,7 @@ static void load_user_kb(void)
"move_tableft=<Alt>Page_Up\n"
"move_tabright=<Alt>Page_Down\n";

utils_write_file(configfile, g_file_test(geanyconf, G_FILE_TEST_EXISTS) ?
utils_write_file(configfile, utils_file_exists(geanyconf) ?
data : "");
g_free(geanyconf);
}
Expand Down
4 changes: 2 additions & 2 deletions src/keyfile.c
Expand Up @@ -1123,7 +1123,7 @@ gboolean configuration_load(void)
gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
GKeyFile *config = g_key_file_new();

if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR))
if (! utils_file_is_regular(configfile))
{ /* config file does not (yet) exist, so try to load a global config file which may be */
/* created by distributors */
geany_debug("No user config file found, trying to use global configuration.");
Expand Down Expand Up @@ -1179,7 +1179,7 @@ static gboolean open_session_file(gchar **tmp, guint len)
if (len > 8)
line_breaking = atoi(tmp[8]);

if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR))
if (utils_file_is_regular(locale_filename))
{
GeanyFiletype *ft = filetypes_lookup_by_name(ft_name);
GeanyDocument *doc = document_open_file_full(
Expand Down
24 changes: 12 additions & 12 deletions src/libmain.c
Expand Up @@ -344,7 +344,7 @@ static void get_line_and_column_from_filename(gchar *filename, gint *line, gint
return;

/* allow to open files like "test:0" */
if (g_file_test(filename, G_FILE_TEST_EXISTS))
if (utils_file_exists(filename))
return;

len = strlen(filename);
Expand Down Expand Up @@ -637,7 +637,7 @@ static gint create_config_dir(void)
gchar *filedefs_dir = NULL;
gchar *templates_dir = NULL;

if (! g_file_test(app->configdir, G_FILE_TEST_EXISTS))
if (! utils_file_exists(app->configdir))
{
#ifndef G_OS_WIN32
/* if we are *not* using an alternate config directory, we check whether the old one
Expand All @@ -646,15 +646,15 @@ static gint create_config_dir(void)
{
gchar *old_dir = g_build_filename(g_get_home_dir(), ".geany", NULL);
/* move the old config dir if it exists */
if (g_file_test(old_dir, G_FILE_TEST_EXISTS))
if (utils_file_exists(old_dir))
{
if (! dialogs_show_question_full(main_widgets.window,
GTK_STOCK_YES, GTK_STOCK_QUIT, _("Move it now?"),
"%s",
_("Geany needs to move your old configuration directory before starting.")))
exit(0);

if (! g_file_test(app->configdir, G_FILE_TEST_IS_DIR))
if (! utils_file_is_dir(app->configdir))
utils_mkdir(app->configdir, TRUE);

if (g_rename(old_dir, app->configdir) == 0)
Expand Down Expand Up @@ -686,7 +686,7 @@ static gint create_config_dir(void)
filedefs_dir = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
templates_dir = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);

if (saved_errno == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
if (saved_errno == 0 && ! utils_file_exists(conf_file))
{ /* check whether geany.conf can be written */
saved_errno = utils_is_file_writable(app->configdir);
}
Expand All @@ -697,11 +697,11 @@ static gint create_config_dir(void)
gchar *filedefs_readme = g_build_filename(app->configdir,
GEANY_FILEDEFS_SUBDIR, "filetypes.README", NULL);

if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
if (! utils_file_exists(filedefs_dir))
{
saved_errno = utils_mkdir(filedefs_dir, FALSE);
}
if (saved_errno == 0 && ! g_file_test(filedefs_readme, G_FILE_TEST_EXISTS))
if (saved_errno == 0 && ! utils_file_exists(filedefs_readme))
{
gchar *text = g_strconcat(
"Copy files from ", app->datadir, " to this directory to overwrite "
Expand All @@ -719,11 +719,11 @@ static gint create_config_dir(void)
gchar *templates_readme = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR,
"templates.README", NULL);

if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
if (! utils_file_exists(templates_dir))
{
saved_errno = utils_mkdir(templates_dir, FALSE);
}
if (saved_errno == 0 && ! g_file_test(templates_readme, G_FILE_TEST_EXISTS))
if (saved_errno == 0 && ! utils_file_exists(templates_readme))
{
gchar *text = g_strconcat(
"There are several template files in this directory. For these templates you can use wildcards.\n\
Expand Down Expand Up @@ -760,7 +760,7 @@ static gint setup_config_dir(void)
}
}
/* make configdir a real path */
if (g_file_test(app->configdir, G_FILE_TEST_EXISTS))
if (utils_file_exists(app->configdir))
SETPTR(app->configdir, tm_get_real_path(app->configdir));

return mkdir_result;
Expand Down Expand Up @@ -798,7 +798,7 @@ gboolean main_handle_filename(const gchar *locale_filename)
if (column >= 0)
cl_options.goto_column = column;

if (g_file_test(filename, G_FILE_TEST_IS_REGULAR))
if (utils_file_is_regular(filename))
{
doc = document_open_file(filename, cl_options.readonly, NULL, NULL);
/* add recent file manually if opening_session_files is set */
Expand Down Expand Up @@ -836,7 +836,7 @@ static void open_cl_files(gint argc, gchar **argv)
{
gchar *filename = main_get_argv_filename(argv[i]);

if (g_file_test(filename, G_FILE_TEST_IS_DIR))
if (utils_file_is_dir(filename))
{
g_free(filename);
continue;
Expand Down
6 changes: 3 additions & 3 deletions src/msgwindow.c
Expand Up @@ -664,7 +664,7 @@ static gboolean goto_compiler_file_line(const gchar *fname, gint line, gboolean
/* If the path doesn't exist, try the current document.
* This happens when we receive build messages in the wrong order - after the
* 'Leaving directory' messages */
if (!g_file_test(filename, G_FILE_TEST_EXISTS))
if (!utils_file_exists(filename))
{
gchar *cur_dir = utils_get_current_file_dir_utf8();
gchar *name;
Expand All @@ -677,7 +677,7 @@ static gboolean goto_compiler_file_line(const gchar *fname, gint line, gboolean
SETPTR(name, g_build_path(G_DIR_SEPARATOR_S, cur_dir, name, NULL));
g_free(cur_dir);

if (g_file_test(name, G_FILE_TEST_EXISTS))
if (utils_file_exists(name))
{
ui_set_statusbar(FALSE, _("Could not find file '%s' - trying the current document path."),
fname);
Expand Down Expand Up @@ -1081,7 +1081,7 @@ static void msgwin_parse_generic_line(const gchar *string, gchar **filename, gin
}

/* if we aren't sure we got a supposedly correct filename, check it */
if (incertain && ! g_file_test(*filename, G_FILE_TEST_EXISTS))
if (incertain && ! utils_file_exists(*filename))
{
SETPTR(*filename, NULL);
*line = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins.c
Expand Up @@ -1084,7 +1084,7 @@ load_active_plugins(void)
*p = G_DIR_SEPARATOR;
#endif

if (!EMPTY(fname) && g_file_test(fname, G_FILE_TEST_EXISTS))
if (!EMPTY(fname) && utils_file_exists(fname))
{
PluginProxy *proxy = NULL;
if (check_plugin_path(fname))
Expand Down