summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-file-utilities.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnautilus-private/nautilus-file-utilities.c')
-rw-r--r--libnautilus-private/nautilus-file-utilities.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 2c88a80b9..ff0221838 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include "nautilus-file.h"
#include "nautilus-link-set.h"
#include "nautilus-metadata.h"
@@ -1190,6 +1191,23 @@ nautilus_copy_uri_simple ( const char *source_uri, const char *dest_uri)
return result;
}
+char *
+nautilus_unique_temporary_file_name (void)
+{
+ const char *prefix = "/tmp/nautilus-temp-file";
+ char *file_name;
+ static guint count = 1;
+
+ file_name = g_strdup_printf ("%sXXXXXX", prefix);
+
+ if (mktemp (file_name) != file_name) {
+ g_free (file_name);
+ file_name = g_strdup_printf ("%s-%d-%d", prefix, count++, getpid ());
+ }
+
+ return file_name;
+}
+
#ifdef EAZEL_BUILD_TIMESTAMP
static const char *BUILD_TIMESTAMP = EAZEL_BUILD_TIMESTAMP;
#else