Revision: 4670 http://geany.svn.sourceforge.net/geany/?rev=4670&view=rev Author: statc Date: 2010-02-15 09:41:12 +0000 (Mon, 15 Feb 2010)
Log Message: ----------- Use absolute paths to project files. Particularly, paths to recent projects' files are now stored as absolute.
Modified Paths: -------------- branches/sm/ChangeLog branches/sm/src/project.c branches/sm/src/sm.c branches/sm/src/utils.c branches/sm/src/utils.h
Modified: branches/sm/ChangeLog =================================================================== --- branches/sm/ChangeLog 2010-02-14 16:57:07 UTC (rev 4669) +++ branches/sm/ChangeLog 2010-02-15 09:41:12 UTC (rev 4670) @@ -1,3 +1,10 @@ +2010-02-15 Eugene Arshinov <earshinov(at)gmail(dot)com> + + * src/project.c, src/sm.c, src/utils.c, src/utils.h: + Use absolute paths to project files. Particularly, paths to recent + projects' files are now stored as absolute. + + 2010-02-07 Eugene Arshinov <earshinov(at)gmail(dot)com>
* src/main.c:
Modified: branches/sm/src/project.c =================================================================== --- branches/sm/src/project.c 2010-02-14 16:57:07 UTC (rev 4669) +++ branches/sm/src/project.c 2010-02-15 09:41:12 UTC (rev 4670) @@ -724,7 +724,8 @@ p = app->project;
setptr(p->name, g_strdup(name)); - setptr(p->file_name, g_strdup(file_name)); + setptr(p->file_name, utils_get_absolute_path(file_name)); + /* use "." if base_path is empty */ setptr(p->base_path, g_strdup(NZV(base_path) ? base_path : "./"));
@@ -929,12 +930,8 @@
if (load_config(locale_file_name)) { - gchar *utf8_filename = utils_get_utf8_from_locale(locale_file_name); - ui_set_statusbar(TRUE, _("Project "%s" opened."), app->project->name); - - ui_add_recent_project_file(utf8_filename); - g_free(utf8_filename); + ui_add_recent_project_file(app->project->file_name); return TRUE; } else @@ -956,6 +953,7 @@ { GKeyFile *config; GeanyProject *p; + gchar *utf8_filename;
/* there should not be an open project */ g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE); @@ -968,12 +966,13 @@ }
p = create_project(); + utf8_filename = utils_get_utf8_from_locale(filename);
stash_group_load_from_key_file(indent_group, config);
p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED); p->description = utils_get_setting_string(config, "project", "description", ""); - p->file_name = utils_get_utf8_from_locale(filename); + p->file_name = utils_get_absolute_path(utf8_filename); p->base_path = utils_get_setting_string(config, "project", "base_path", ""); p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);
@@ -990,6 +989,7 @@ g_signal_emit_by_name(geany_object, "project-open", config); g_key_file_free(config);
+ g_free(utf8_filename); update_ui(); return TRUE; }
Modified: branches/sm/src/sm.c =================================================================== --- branches/sm/src/sm.c 2010-02-14 16:57:07 UTC (rev 4669) +++ branches/sm/src/sm.c 2010-02-15 09:41:12 UTC (rev 4670) @@ -323,14 +323,8 @@ */ if (strchr(argv0, G_DIR_SEPARATOR) == NULL) executable_path = argv0; - else if (g_path_is_absolute(argv0)) - executable_path = argv0; else - { - gchar * curdir = g_get_current_dir(); - executable_path = g_build_filename(curdir, argv0, NULL); /* never freed */ - g_free(curdir); - } + executable_path = utils_get_absolute_path(argv0); /* never freed */ sm_program_val.length = strlen(executable_path); sm_program_val.value = (char *)executable_path;
Modified: branches/sm/src/utils.c =================================================================== --- branches/sm/src/utils.c 2010-02-14 16:57:07 UTC (rev 4669) +++ branches/sm/src/utils.c 2010-02-15 09:41:12 UTC (rev 4670) @@ -1973,3 +1973,21 @@ } return ret; } + + +/* Get absolute path corresponding to @c filename relative to the current directory. + * If given @c filename is already absolute, it is just copied and returned. + * @param filename file path, relative or absolute + * @return absolute file path, must be g_free()'d when no longer needed */ +gchar *utils_get_absolute_path(const gchar *filename) +{ + if (g_path_is_absolute(filename)) + return g_strdup(filename); + else + { + gchar *curdir = g_get_current_dir(); + gchar *ret = g_build_filename(curdir, filename, NULL); + g_free(curdir); + return ret; + } +}
Modified: branches/sm/src/utils.h =================================================================== --- branches/sm/src/utils.h 2010-02-14 16:57:07 UTC (rev 4669) +++ branches/sm/src/utils.h 2010-02-15 09:41:12 UTC (rev 4670) @@ -231,4 +231,6 @@
GArray * utils_option_entry_reverse_parse(const GOptionEntry * optentry);
+gchar *utils_get_absolute_path(const gchar *filename); + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.