Remove utils_build_path() - use g_build_filename instead

This commit is contained in:
Nick Treleaven 2012-02-06 16:41:18 +00:00
parent e7befb410c
commit 9426104f0b
9 changed files with 22 additions and 63 deletions

View File

@ -4734,7 +4734,7 @@ void editor_destroy(GeanyEditor *editor)
static void on_document_save(GObject *obj, GeanyDocument *doc) static void on_document_save(GObject *obj, GeanyDocument *doc)
{ {
gchar *f = utils_build_path(app->configdir, "snippets.conf", NULL); gchar *f = g_build_filename(app->configdir, "snippets.conf", NULL);
g_return_if_fail(NZV(doc->real_path)); g_return_if_fail(NZV(doc->real_path));
@ -4781,7 +4781,7 @@ void editor_init(void)
* handler (on_editor_notify) is called */ * handler (on_editor_notify) is called */
g_signal_connect_after(geany_object, "editor-notify", G_CALLBACK(on_editor_notify), NULL); g_signal_connect_after(geany_object, "editor-notify", G_CALLBACK(on_editor_notify), NULL);
f = utils_build_path(app->configdir, "snippets.conf", NULL); f = g_build_filename(app->configdir, "snippets.conf", NULL);
ui_add_config_file_menu_item(f, NULL, NULL); ui_add_config_file_menu_item(f, NULL, NULL);
g_free(f); g_free(f);
g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL); g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);

View File

@ -644,7 +644,7 @@ void filetypes_init_types()
filetype_add(filetypes[ft_id]); filetype_add(filetypes[ft_id]);
} }
init_custom_filetypes(app->datadir); init_custom_filetypes(app->datadir);
f = utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL); f = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
init_custom_filetypes(f); init_custom_filetypes(f);
g_free(f); g_free(f);
@ -662,12 +662,12 @@ static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
g_return_if_fail(NZV(doc->real_path)); g_return_if_fail(NZV(doc->real_path));
f = utils_build_path(app->configdir, "filetype_extensions.conf", NULL); f = g_build_filename(app->configdir, "filetype_extensions.conf", NULL);
if (utils_str_equal(doc->real_path, f)) if (utils_str_equal(doc->real_path, f))
filetypes_reload_extensions(); filetypes_reload_extensions();
g_free(f); g_free(f);
f = utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.common", NULL); f = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.common", NULL);
if (utils_str_equal(doc->real_path, f)) if (utils_str_equal(doc->real_path, f))
{ {
guint i; guint i;
@ -687,9 +687,9 @@ static void setup_config_file_menus(void)
{ {
gchar *f; gchar *f;
f = utils_build_path(app->configdir, "filetype_extensions.conf", NULL); f = g_build_filename(app->configdir, "filetype_extensions.conf", NULL);
ui_add_config_file_menu_item(f, NULL, NULL); ui_add_config_file_menu_item(f, NULL, NULL);
SETPTR(f, utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.common", NULL)); SETPTR(f, g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.common", NULL));
ui_add_config_file_menu_item(f, NULL, NULL); ui_add_config_file_menu_item(f, NULL, NULL);
g_free(f); g_free(f);
@ -808,11 +808,11 @@ static GeanyFiletype *check_builtin_filenames(const gchar *utf8_filename)
#endif #endif
SETPTR(lfn, utils_get_locale_from_utf8(lfn)); SETPTR(lfn, utils_get_locale_from_utf8(lfn));
path = utils_build_path(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.", NULL); path = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, "filetypes.", NULL);
if (g_str_has_prefix(lfn, path)) if (g_str_has_prefix(lfn, path))
found = TRUE; found = TRUE;
SETPTR(path, utils_build_path(app->datadir, "filetypes.", NULL)); SETPTR(path, g_build_filename(app->datadir, "filetypes.", NULL));
if (g_str_has_prefix(lfn, path)) if (g_str_has_prefix(lfn, path))
found = TRUE; found = TRUE;

View File

@ -1230,9 +1230,9 @@ static void add_color_scheme_item(GtkWidget *menu, const gchar *fname)
gchar *path, *theme_name, *tooltip; gchar *path, *theme_name, *tooltip;
gchar *theme_fn = utils_get_utf8_from_locale(fname); gchar *theme_fn = utils_get_utf8_from_locale(fname);
path = utils_build_path(app->configdir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL); path = g_build_filename(app->configdir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL);
hkeyfile = utils_key_file_new(path); hkeyfile = utils_key_file_new(path);
SETPTR(path, utils_build_path(app->datadir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL)); SETPTR(path, g_build_filename(app->datadir, GEANY_COLORSCHEMES_SUBDIR, fname, NULL));
skeyfile = utils_key_file_new(path); skeyfile = utils_key_file_new(path);
theme_name = utils_get_setting(locale_string, hkeyfile, skeyfile, "theme_info", "name", theme_fn); theme_name = utils_get_setting(locale_string, hkeyfile, skeyfile, "theme_info", "name", theme_fn);

View File

@ -978,7 +978,7 @@ void configuration_save_default_session(void)
*/ */
void configuration_reload_default_session(void) void configuration_reload_default_session(void)
{ {
const gchar *configfile = utils_build_path(app->configdir, "geany.conf", NULL); const gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
GKeyFile *config = g_key_file_new(); GKeyFile *config = g_key_file_new();
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
@ -991,14 +991,14 @@ void configuration_reload_default_session(void)
gboolean configuration_load(void) gboolean configuration_load(void)
{ {
gchar *configfile = utils_build_path(app->configdir, "geany.conf", NULL); gchar *configfile = g_build_filename(app->configdir, "geany.conf", NULL);
GKeyFile *config = g_key_file_new(); GKeyFile *config = g_key_file_new();
if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR)) if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR))
{ /* config file does not (yet) exist, so try to load a global config file which may be */ { /* config file does not (yet) exist, so try to load a global config file which may be */
/* created by distributors */ /* created by distributors */
geany_debug("No user config file found, trying to use global configuration."); geany_debug("No user config file found, trying to use global configuration.");
SETPTR(configfile, utils_build_path(app->datadir, "geany.conf", NULL)); SETPTR(configfile, g_build_filename(app->datadir, "geany.conf", NULL));
} }
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
g_free(configfile); g_free(configfile);

View File

@ -1732,7 +1732,7 @@ static GHashTable *init_user_tags(void)
GHashTable *lang_hash; GHashTable *lang_hash;
gchar *dir; gchar *dir;
dir = utils_build_path(app->configdir, "tags", NULL); dir = g_build_filename(app->configdir, "tags", NULL);
/* create the user tags dir for next time if it doesn't exist */ /* create the user tags dir for next time if it doesn't exist */
if (! g_file_test(dir, G_FILE_TEST_IS_DIR)) if (! g_file_test(dir, G_FILE_TEST_IS_DIR))
{ {
@ -1740,7 +1740,7 @@ static GHashTable *init_user_tags(void)
} }
file_list = utils_get_file_list_full(dir, TRUE, TRUE, NULL); file_list = utils_get_file_list_full(dir, TRUE, TRUE, NULL);
SETPTR(dir, utils_build_path(app->datadir, "tags", NULL)); SETPTR(dir, g_build_filename(app->datadir, "tags", NULL));
list = utils_get_file_list_full(dir, TRUE, TRUE, NULL); list = utils_get_file_list_full(dir, TRUE, TRUE, NULL);
g_free(dir); g_free(dir);
@ -2171,7 +2171,7 @@ static void create_taglist_popup_menu(void)
static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc) static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
{ {
gchar *f = utils_build_path(app->configdir, "ignore.tags", NULL); gchar *f = g_build_filename(app->configdir, "ignore.tags", NULL);
g_return_if_fail(NZV(doc->real_path)); g_return_if_fail(NZV(doc->real_path));
@ -2188,7 +2188,7 @@ void symbols_init(void)
create_taglist_popup_menu(); create_taglist_popup_menu();
f = utils_build_path(app->configdir, "ignore.tags", NULL); f = g_build_filename(app->configdir, "ignore.tags", NULL);
ui_add_config_file_menu_item(f, NULL, NULL); ui_add_config_file_menu_item(f, NULL, NULL);
g_free(f); g_free(f);

View File

@ -298,7 +298,7 @@ static void on_file_menu_hide(GtkWidget *item)
/* reload templates if any file in the templates path is saved */ /* reload templates if any file in the templates path is saved */
static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc) static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
{ {
gchar *path = utils_build_path(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL); gchar *path = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);
g_return_if_fail(NZV(doc->real_path)); g_return_if_fail(NZV(doc->real_path));

View File

@ -215,7 +215,7 @@ static GtkWidget *toolbar_reload(const gchar *markup)
else else
{ {
/* Load the toolbar UI XML file from disk (first from config dir, then try data dir) */ /* Load the toolbar UI XML file from disk (first from config dir, then try data dir) */
filename = utils_build_path(app->configdir, "ui_toolbar.xml", NULL); filename = g_build_filename(app->configdir, "ui_toolbar.xml", NULL);
merge_id = gtk_ui_manager_add_ui_from_file(uim, filename, &error); merge_id = gtk_ui_manager_add_ui_from_file(uim, filename, &error);
if (merge_id == 0) if (merge_id == 0)
{ {
@ -224,7 +224,7 @@ static GtkWidget *toolbar_reload(const gchar *markup)
g_error_free(error); g_error_free(error);
error = NULL; error = NULL;
SETPTR(filename, utils_build_path(app->datadir, "ui_toolbar.xml", NULL)); SETPTR(filename, g_build_filename(app->datadir, "ui_toolbar.xml", NULL));
merge_id = gtk_ui_manager_add_ui_from_file(uim, filename, &error); merge_id = gtk_ui_manager_add_ui_from_file(uim, filename, &error);
} }
g_free(filename); g_free(filename);
@ -897,7 +897,7 @@ at http://www.geany.org/manual/current/index.html#customizing-the-toolbar.\n-->\
toolbar_reload(str->str); toolbar_reload(str->str);
filename = utils_build_path(app->configdir, "ui_toolbar.xml", NULL); filename = g_build_filename(app->configdir, "ui_toolbar.xml", NULL);
utils_write_file(filename, str->str); utils_write_file(filename, str->str);
g_free(filename); g_free(filename);

View File

@ -1754,45 +1754,6 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
} }
static gboolean utils_string_vappend(GString *buffer, const gchar *sep, va_list args)
{
const gchar *str = va_arg(args, const gchar *);
if (!str)
return FALSE;
do
{
g_string_append(buffer, str);
str = va_arg(args, const gchar *);
if (str && sep)
g_string_append(buffer, sep);
}
while (str);
return TRUE;
}
/* Like g_build_path() but without first argument. */
gchar *utils_build_path(const gchar *first, ...)
{
static GString *buffer = NULL;
va_list args;
if (! buffer)
buffer = g_string_new(first);
else
g_string_assign(buffer, first);
g_string_append_c(buffer, G_DIR_SEPARATOR);
va_start(args, first);
utils_string_vappend(buffer, G_DIR_SEPARATOR_S, args);
va_end(args);
return g_strdup(buffer->str);
}
/* Retrieves the path for the given URI. /* Retrieves the path for the given URI.
* It returns: * It returns:
* - the path which was determined by g_filename_from_uri() or GIO * - the path which was determined by g_filename_from_uri() or GIO

View File

@ -264,8 +264,6 @@ gboolean utils_spawn_async(const gchar *dir, gchar **argv, gchar **env, GSpawnFl
gint utils_str_casecmp(const gchar *s1, const gchar *s2); gint utils_str_casecmp(const gchar *s1, const gchar *s2);
gchar *utils_build_path(const gchar *first, ...) G_GNUC_NULL_TERMINATED;
gchar *utils_get_path_from_uri(const gchar *uri); gchar *utils_get_path_from_uri(const gchar *uri);
gboolean utils_is_uri(const gchar *uri); gboolean utils_is_uri(const gchar *uri);