Add g_mkdtemp in the spirit of g_mkstemp

At the same time, also add g_mkdtemp_full and g_dir_make_tmp
variants. The patch also unifies the unique-name-generating
code for all variants of mkstemp and mkdtemp and adds tests
for the new functions.

Based on patches by Paolo Bonzini,
http://bugzilla.gnome.org/show_bug.cgi?id=118563
This commit is contained in:
Matthias Clasen
2011-08-14 14:09:58 -04:00
parent 8377a88685
commit b76bb6713b
5 changed files with 316 additions and 163 deletions

View File

@@ -99,16 +99,23 @@ gboolean g_file_set_contents (const gchar *filename,
gchar *g_file_read_link (const gchar *filename,
GError **error);
/* Wrapper / workalike for mkdtemp() */
gchar *g_mkdtemp (gchar *tmpl);
gchar *g_mkdtemp_full (gchar *tmpl,
gint mode);
/* Wrapper / workalike for mkstemp() */
gint g_mkstemp (gchar *tmpl);
gint g_mkstemp_full (gchar *tmpl,
int flags,
int mode);
gint flags,
gint mode);
/* Wrapper for g_mkstemp */
/* Wrappers for g_mkstemp and g_mkdtemp() */
gint g_file_open_tmp (const gchar *tmpl,
gchar **name_used,
GError **error);
gchar **name_used,
GError **error);
gchar *g_dir_make_tmp (const gchar *tmpl,
GError **error);
typedef enum
{