After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 118563 - Add g_mkdtemp in the spirit of g_mkstemp
Add g_mkdtemp in the spirit of g_mkstemp
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.2.x
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 150091 343909 524831 615898 (view as bug list)
Depends on:
Blocks: 141319 623890
 
 
Reported: 2003-07-29 09:46 UTC by Fredrik Jönsson
Modified: 2011-08-14 18:18 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch to add a g_mkdtemp call to glib (3.89 KB, patch)
2003-07-29 09:47 UTC, Fredrik Jönsson
needs-work Details | Review
updated g_mkdtemp() patch with Owen's suggestion (5.36 KB, patch)
2010-04-17 16:57 UTC, Jeffrey Stedfast
none Details | Review
make g_mkstemp, g_mkdtemp, and g_mkstemp_full all simple wrappers around an internal function that does everything (6.69 KB, patch)
2010-04-17 17:34 UTC, Jeffrey Stedfast
none Details | Review
make g_mkstemp, g_mkdtemp, and g_mkstemp_full all simple wrappers around an internal function that does everything (6.42 KB, patch)
2010-04-17 17:40 UTC, Jeffrey Stedfast
none Details | Review
patch to implement g_dir_make_tmp (6.93 KB, patch)
2010-04-19 17:35 UTC, Paolo Bonzini
none Details | Review

Description Fredrik Jönsson 2003-07-29 09:46:35 UTC
Add a g_mkdtemp in the spirit of g_mkstemp for the benefit of non-glibc
based platforms. Make it a thin wrapper on mkdtemp for platforms that has
it. Patch attached below. Should be checked against the glibc
implementation, doesn't have it as of this writing.
Comment 1 Fredrik Jönsson 2003-07-29 09:47:13 UTC
Created attachment 18714 [details] [review]
Patch to add a g_mkdtemp call to glib
Comment 2 Matthias Clasen 2003-07-29 10:16:02 UTC
If we add this we should probably also add a more glib-style function 
parallel to g_file_open_tmp, e.g




void g_dir_create_tmp (const gchar *tmpl,


                       gchar      **name_used,


                       GError     **error);
Comment 3 Owen Taylor 2003-08-06 19:30:54 UTC
In terms of implementation, I don't think duplicating a big
chunk of random name generation code between mkdtemp
and mkstemp makes sense, so that should be unified in
some way. 

(glibc makes all of mkstemp/mkdtemp/mktemp
simply wrappers that call __gen_tempname (template, __GT_DIR)), 
etc.)
Comment 4 Owen Taylor 2004-08-16 15:24:59 UTC
*** Bug 150091 has been marked as a duplicate of this bug. ***
Comment 5 Elijah Newren 2006-06-05 18:03:04 UTC
*** Bug 343909 has been marked as a duplicate of this bug. ***
Comment 6 Reinout van Schouwen 2007-08-03 14:02:13 UTC
Is this still valid?
Comment 7 Matthias Clasen 2008-08-15 03:28:31 UTC
*** Bug 524831 has been marked as a duplicate of this bug. ***
Comment 8 Matthias Clasen 2008-08-15 03:29:21 UTC
The last dupe has an alternative patch
Comment 9 Jeffrey Stedfast 2008-08-15 11:21:43 UTC
looks like the main difference is that my patch allows the XXXXXX to be anywhere in the string (just like g_mkstemp and friends) whereas the patch in this bug report uses mkdtemp() if it is available (which breaks the expected behavior of allowing the XXXXXX to be anywhere in the string but the end).
Comment 10 Jeffrey Stedfast 2010-04-17 16:57:07 UTC
Created attachment 158959 [details] [review]
updated g_mkdtemp() patch with Owen's suggestion

This patch, like my previous patch, is consistent with g_mkstemp(), allowing the XXXXXX to be anywhere in the template string.

I've also taken Owen's suggestion and split out the code that fills in the XXXXXX with random chars and updated all of the functions to use that (including the new g_mkdtemp() function).
Comment 11 Jeffrey Stedfast 2010-04-17 17:34:57 UTC
Created attachment 158963 [details] [review]
make g_mkstemp, g_mkdtemp, and g_mkstemp_full all simple wrappers around an internal function that does everything

this patch makes g_mkstemp, g_mkdtemp, and g_mkstemp_full all simple wrappers around an internal g_mktemp function that does everything, not just the XXXXXX logic.
Comment 12 Jeffrey Stedfast 2010-04-17 17:40:57 UTC
Created attachment 158965 [details] [review]
make g_mkstemp, g_mkdtemp, and g_mkstemp_full all simple wrappers around an internal function that does everything

Oops, this fixes the second g_mkstemp implementation at the end of the file
Comment 13 Paolo Bonzini 2010-04-19 16:40:24 UTC
*** Bug 615898 has been marked as a duplicate of this bug. ***
Comment 14 Paolo Bonzini 2010-04-19 16:41:22 UTC
See also attachment 158852 [details] [review] from bug 615898, which uses a more flexible internal function and thus commonizes also the legacy (non-UTF8) g_mkstemp implementation.
Comment 15 Paolo Bonzini 2010-04-19 16:41:51 UTC
... and includes testcases. :-)
Comment 16 Paolo Bonzini 2010-04-19 17:35:24 UTC
Created attachment 159093 [details] [review]
patch to implement g_dir_make_tmp

Addendum patch to attachment 158852 [details] [review], implements a variant with GError support.
Comment 17 Paolo Bonzini 2011-01-20 17:24:55 UTC
ping for patch of comment 16?
Comment 18 David Woodhouse 2011-04-19 17:11:17 UTC
Evolution-EWS needs a mkdtemp too...
Comment 19 Matthias Clasen 2011-08-14 18:18:04 UTC
I've committed Paolo's patches. Thanks, and sorry for the long wait.