mirror of https://github.com/djcb/mu.git
* add mu_util_create_tmpdir
This commit is contained in:
parent
56cfe14062
commit
65e4f8b896
|
@ -111,6 +111,27 @@ mu_util_dir_expand (const char *path)
|
|||
return g_strdup (resolved);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
mu_util_create_tmpdir (void)
|
||||
{
|
||||
gchar *dirname;
|
||||
dirname = g_strdup_printf ("%s%cmu-%d%c%x", g_get_tmp_dir(),
|
||||
G_DIR_SEPARATOR,
|
||||
getuid(),
|
||||
G_DIR_SEPARATOR,
|
||||
(int)random()*getpid()*(int)time(NULL));
|
||||
|
||||
if (!mu_util_create_dir_maybe (dirname)) {
|
||||
g_free (dirname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dirname;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
mu_util_init_system (void)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,16 @@ gboolean mu_util_create_dir_maybe (const gchar *path)
|
|||
G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
/**
|
||||
* create a temporary dir (typically, in /tmp) with a unique name,
|
||||
* such that files can be saved there.
|
||||
*
|
||||
* @return the name of the new dir, or NULL in case of error. Free with g_free
|
||||
*/
|
||||
char* mu_util_create_tmpdir (void)
|
||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
/**
|
||||
* check whether path is a directory, and optionally, if it's readable
|
||||
* and/or writeable
|
||||
|
@ -178,7 +188,7 @@ gboolean mu_util_clear_database (const gchar *xpath);
|
|||
* @return a newly allocated string
|
||||
*/
|
||||
gchar* mu_util_str_from_strv (const gchar **params)
|
||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
/*
|
||||
* for OSs with out support for direntry->d_type, like Solaris
|
||||
|
|
Loading…
Reference in New Issue