[geany/geany] b7c4bb: Create correct path for filetype config files

Jiří Techet git-noreply at xxxxx
Fri Aug 4 06:41:21 UTC 2017


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Matthew Brush <mbrush at codebrainz.ca>
Date:        Fri, 04 Aug 2017 06:41:21 UTC
Commit:      b7c4bb0b4d3022bb0102627cb6baa854cec93dd1
             https://github.com/geany/geany/commit/b7c4bb0b4d3022bb0102627cb6baa854cec93dd1

Log Message:
-----------
Create correct path for filetype config files

Since filedef config files are now stored under the "filedef" subdirectory
of app->datadir, we need to add the subdirectory name when creating path
from the corresponding app->configdir otherwise the file isn't found.

Closes #1482


Modified Paths:
--------------
    src/ui_utils.c

Modified: src/ui_utils.c
17 lines changed, 15 insertions(+), 2 deletions(-)
===================================================================
@@ -2095,10 +2095,23 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
 	else
 	{
 		gchar *utf8_filename = utils_get_utf8_from_locale(file_name);
-		gchar *base_name = g_path_get_basename(file_name);
-		gchar *global_file = g_build_filename(app->datadir, base_name, NULL);
+		gchar *global_file;
+		gchar *base_name = NULL;
 		gchar *global_content = NULL;
 
+		/* get the path inside app->configdir - can contain subdirectories */
+		if (g_str_has_prefix(file_name, app->configdir))
+		{
+			gsize len = strlen(app->configdir);
+			if (file_name[len] == G_DIR_SEPARATOR)
+				base_name = g_strdup(file_name + len + 1);
+		}
+
+		if (!base_name)
+			base_name = g_path_get_basename(file_name);
+
+		global_file = g_build_filename(app->datadir, base_name, NULL);
+
 		/* if the requested file doesn't exist in the user's config dir, try loading the file
 		 * from the global data directory and use its contents for the newly created file */
 		if (g_file_test(global_file, G_FILE_TEST_EXISTS))



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list