[Github-comments] [geany/geany] SaveActions: Add configurable target directory for instantly saved files (#2769)
Enrico Tröger
notifications at xxxxx
Mon Mar 29 21:44:31 UTC 2021
@eht16 commented on this pull request.
> 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?
As per docs, no. So we handle now errors by showing them to the user and cancelling Instant Save.
> Also since g_mkstemp() makes a file the now non-temporary file directory gets two files, for example `gis_setv00` and `gis_setv00.c`.
Good catch! Fixed by first constructing the final filename and then call `g_mkstemp()` to have the file created.
--
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#discussion_r603633932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20210329/e37b21e2/attachment-0001.htm>
More information about the Github-comments
mailing list