[Github-comments] [geany/geany] Create project's filename path (#2586)

Matthew Brush notifications at xxxxx
Tue Sep 15 01:41:33 UTC 2020


@codebrainz commented on this pull request.



> +			/* get last path_delimiter so we know the path */
+			int i;
+			int last_path_delimiter;
+			for (i = 0; locale_filename[i] != '\0'; ++i) {
+				if (locale_filename[i] == path_delimiter) {
+					last_path_delimiter = i;
+				}
+			}
+
+			/* get substring containing only the filename path */
+			gchar *filename_path = g_malloc((last_path_delimiter + 2) * sizeof(char));
+			strncpy(filename_path, locale_filename, last_path_delimiter + 1);
+			filename_path[last_path_delimiter + 1] = '\0';

If I understand correctly the intention here, I believe these lines could be reduced to:

```c
gchar *filename_path = g_path_get_dirname(locale_filename);
```

GLib makes C quite a bit less painful :wink: 

-- 
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/2586#pullrequestreview-488264298
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20200914/19ec4769/attachment.htm>


More information about the Github-comments mailing list