diff options
Diffstat (limited to 'libdocument')
-rw-r--r-- | libdocument/ev-attachment.c | 2 | ||||
-rw-r--r-- | libdocument/ev-document-factory.c | 9 | ||||
-rw-r--r-- | libdocument/ev-file-helpers.c | 37 | ||||
-rw-r--r-- | libdocument/ev-file-helpers.h | 3 | ||||
-rw-r--r-- | libdocument/ev-image.c | 2 |
5 files changed, 43 insertions, 10 deletions
diff --git a/libdocument/ev-attachment.c b/libdocument/ev-attachment.c index 7e7ca12..980d056 100644 --- a/libdocument/ev-attachment.c +++ b/libdocument/ev-attachment.c @@ -97,7 +97,7 @@ ev_attachment_finalize (GObject *object) } if (attachment->priv->tmp_uri) { - g_unlink (attachment->priv->tmp_uri); + ev_tmp_filename_unlink (attachment->priv->tmp_uri); g_free (attachment->priv->tmp_uri); attachment->priv->tmp_uri = NULL; } diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c index 4adec66..b500fdf 100644 --- a/libdocument/ev-document-factory.c +++ b/libdocument/ev-document-factory.c @@ -312,17 +312,10 @@ get_document_from_uri (const char *uri, static void free_uncompressed_uri (gchar *uri_unc) { - gchar *filename; - if (!uri_unc) return; - filename = g_filename_from_uri (uri_unc, NULL, NULL); - if (!filename) - return; - - g_unlink (filename); - g_free (filename); + ev_tmp_uri_unlink (uri_unc); g_free (uri_unc); } diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c index 82e8543..dd3b3e1 100644 --- a/libdocument/ev-file-helpers.c +++ b/libdocument/ev-file-helpers.c @@ -145,6 +145,43 @@ ev_tmp_filename (const gchar *prefix) return filename; } +/* Remove a local temp file created by evince */ +void +ev_tmp_filename_unlink (const gchar *filename) +{ + const gchar *tempdir; + + if (!filename) + return; + + tempdir = g_get_tmp_dir (); + if (g_ascii_strncasecmp (filename, tempdir, strlen (tempdir)) == 0) { + g_unlink (filename); + } +} + +void +ev_tmp_uri_unlink (const gchar *uri) +{ + GnomeVFSURI *vfs_uri; + gchar *filename; + + if (!uri) + return; + + vfs_uri = gnome_vfs_uri_new (uri); + if (!gnome_vfs_uri_is_local (vfs_uri)) { + g_warning ("Attempting to delete non local uri: %s\n", uri); + gnome_vfs_uri_unref (vfs_uri); + return; + } + gnome_vfs_uri_unref (vfs_uri); + + filename = g_filename_from_uri (uri, NULL, NULL); + ev_tmp_filename_unlink (filename); + g_free (filename); +} + gboolean ev_xfer_uri_simple (const char *from, const char *to, diff --git a/libdocument/ev-file-helpers.h b/libdocument/ev-file-helpers.h index f7d9f9e..6aad12a 100644 --- a/libdocument/ev-file-helpers.h +++ b/libdocument/ev-file-helpers.h @@ -40,10 +40,13 @@ void ev_file_helpers_init (void); void ev_file_helpers_shutdown (void); gchar *ev_tmp_filename (const char *prefix); +void ev_tmp_filename_unlink (const gchar *filename); +void ev_tmp_uri_unlink (const gchar *uri); gboolean ev_xfer_uri_simple (const char *from, const char *to, GError **error); + gchar *ev_file_uncompress (const gchar *uri, EvCompressionType type, GError **error); diff --git a/libdocument/ev-image.c b/libdocument/ev-image.c index f906b00..bcb1e7d 100644 --- a/libdocument/ev-image.c +++ b/libdocument/ev-image.c @@ -42,7 +42,7 @@ ev_image_finalize (GObject *object) } if (image->priv->tmp_uri) { - g_unlink (image->priv->tmp_uri); + ev_tmp_filename_unlink (image->priv->tmp_uri); g_free (image->priv->tmp_uri); image->priv->tmp_uri = NULL; } |