[Github-comments] [geany/geany] Use relative paths for project session files if base directory is relative (PR #3021)
xiota
notifications at xxxxx
Thu Nov 25 22:39:38 UTC 2021
@xiota commented on this pull request.
> @@ -365,6 +365,25 @@ static gchar *get_session_file_string(GeanyDocument *doc)
ft = filetypes[GEANY_FILETYPES_NONE];
locale_filename = utils_get_locale_from_utf8(doc->file_name);
+ /* use relative path for projects with relative base path and files
+ * inside the base path */
+ if (is_project && app->project && !g_path_is_absolute(app->project->base_path))
+ {
+ gchar *project_dir, *relpath, *base_path;
+ GFile *prjdir, *fname;
+
+ base_path = project_get_base_path();
+ project_dir = utils_get_locale_from_utf8(base_path);
+ prjdir = g_file_new_for_path(project_dir);
+ fname = g_file_new_for_path(locale_filename);
+ relpath = g_file_get_relative_path(prjdir, fname);
Could you add a comment to note that `fname` will be `NULL` if `prjdir is not parent of `fname` to make it clear to people (me) who aren't familiar with `g_file_get_relative_path`, that it won't create `../../etc` type paths.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3021#pullrequestreview-816320015
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211125/de4a4612/attachment.htm>
More information about the Github-comments
mailing list