Signed-off-by: Matteo Cafasso <noxdafox(a)gmail.com>
---
src/guestfs-internal.h | 1 +
src/tmpdirs.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index fbbfb90..51d3512 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -813,6 +813,7 @@ extern int guestfs_int_set_env_tmpdir (guestfs_h *g, const char
*envname, const
extern int guestfs_int_set_env_runtimedir (guestfs_h *g, const char *envname, const char
*runtimedir);
extern int guestfs_int_lazy_make_tmpdir (guestfs_h *g);
extern int guestfs_int_lazy_make_sockdir (guestfs_h *g);
+extern char *guestfs_int_make_temp_path (guestfs_h *g, const char *name);
extern char *guestfs_int_lazy_make_supermin_appliance_dir (guestfs_h *g);
extern void guestfs_int_remove_tmpdir (guestfs_h *g);
extern void guestfs_int_remove_sockdir (guestfs_h *g);
diff --git a/src/tmpdirs.c b/src/tmpdirs.c
index 725f683..7d289a6 100644
--- a/src/tmpdirs.c
+++ b/src/tmpdirs.c
@@ -223,6 +223,23 @@ guestfs_int_lazy_make_sockdir (guestfs_h *g)
}
/**
+ * Generate unique temporary paths for temporary files.
+ *
+ * Returns a unique path or NULL on error.
+ */
+char *
+guestfs_int_make_temp_path (guestfs_h *g, const char *name)
+{
+ int ret = 0;
+
+ ret = guestfs_int_lazy_make_tmpdir (g);
+ if (ret < 0)
+ return NULL;
+
+ return safe_asprintf (g, "%s/%s%d", g->tmpdir, name, ++g->unique);
+}
+
+/**
* Create the supermin appliance directory under cachedir, if it does
* not exist.
*
--
2.10.2