[Github-comments] [geany/geany] SaveActions: Add configurable target directory for instantly saved files (#2769)

elextr notifications at xxxxx
Mon Mar 22 09:53:08 UTC 2021


@elextr commented on this pull request.

One new bug and two things I noticed in the original.

>  {
 	gchar *tmp;
 
+	if (target == NULL)
+	{
+		SETPTR(*target, NULL);

`*target` is guaranteed to dereference a NULL?????

>  		gchar *new_filename;
 		gint fd;
 		GeanyFiletype *ft = doc->file_type;
 
-		fd = g_file_open_tmp("gis_XXXXXX", &new_filename, NULL);
+		directory = !EMPTY(instantsave_target_dir) ? instantsave_target_dir : g_get_tmp_dir();
+		new_filename = g_build_filename(directory, "gis_XXXXXX", NULL);
+		fd = g_mkstemp(new_filename);
 		if (fd != -1)
 			close(fd); /* close the returned file descriptor as we only need the filename */
 

If g_mkstemp() returns -1 is the filename valid and usable?

>  		gchar *new_filename;
 		gint fd;
 		GeanyFiletype *ft = doc->file_type;
 
-		fd = g_file_open_tmp("gis_XXXXXX", &new_filename, NULL);
+		directory = !EMPTY(instantsave_target_dir) ? instantsave_target_dir : g_get_tmp_dir();
+		new_filename = g_build_filename(directory, "gis_XXXXXX", NULL);
+		fd = g_mkstemp(new_filename);
 		if (fd != -1)
 			close(fd); /* close the returned file descriptor as we only need the filename */
 

Also since g_mkstemp() makes a file the now non-temporary file directory gets two files, for example `gis_setv00` and `gis_setv_00.c`.

-- 
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/2769#pullrequestreview-617313850
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20210322/7f4342b4/attachment.htm>


More information about the Github-comments mailing list