diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-11-07 08:21:51 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-11-07 08:21:51 +0000 |
commit | 30b5a69fb12303b65a0fadc8f5efe776b6d152f8 (patch) | |
tree | bed1954e608ff677afb529eee0119dd773797b14 /libnautilus-extensions/nautilus-file-utilities.c | |
parent | 7923dc7d883082a42ae44780ad1465144160dffb (diff) | |
download | nautilus-30b5a69fb12303b65a0fadc8f5efe776b6d152f8.tar.gz |
Fix for 4585. Crash saving updates.tgz file from server if it already
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_copy_uri_simple), (nautilus_unique_temporary_file_name):
* libnautilus-extensions/nautilus-file-utilities.h:
* src/nautilus-first-time-druid.c: (download_callback):
Fix for 4585. Crash saving updates.tgz file from server if it
already exists. The fix is to use a unique temporary file name
and cleaning up after untar the update tarball.
Diffstat (limited to 'libnautilus-extensions/nautilus-file-utilities.c')
-rw-r--r-- | libnautilus-extensions/nautilus-file-utilities.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c index 2c88a80b9..ff0221838 100644 --- a/libnautilus-extensions/nautilus-file-utilities.c +++ b/libnautilus-extensions/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 |