diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2007-05-25 16:43:19 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@src.gnome.org> | 2007-05-25 16:43:19 (GMT) |
commit | 3588349bcec38d0915a8e1f0ea3949d683c4eb8c (patch) | |
tree | 4131023aa60a90a8f13f34ee3f964160b2355ede /libdocument/ev-file-helpers.c | |
parent | 741af7a833085db5d6ac2f07c1a2f995a8c955d6 (diff) |
Add functions to delete temporary files created by evince in a safe way.
2007-05-25 Carlos Garcia Campos <carlosgc@gnome.org>
* libdocument/ev-image.c: (ev_image_finalize):
* libdocument/ev-document-factory.c: (free_uncompressed_uri):
* libdocument/ev-attachment.c: (ev_attachment_finalize):
* libdocument/ev-file-helpers.[ch]: (ev_tmp_filename_unlink),
(ev_tmp_uri_unlink):
Add functions to delete temporary files created by evince in a safe
way.
* shell/ev-window.c: (ev_window_clear_local_uri),
(open_xfer_update_progress_callback),
(save_xfer_update_progress_callback), (ev_window_save_remote),
(file_save_dialog_response_cb), (ev_window_cmd_save_as),
(image_save_dialog_response_cb), (ev_view_popup_cmd_save_image_as),
(attachment_save_dialog_response_cb),
(ev_attachment_popup_cmd_save_attachment_as):
Allow saving a copy of a document, image or attachment to a remote
location. Fixes bug #440754.
svn path=/trunk/; revision=2478
Diffstat (limited to 'libdocument/ev-file-helpers.c')
-rw-r--r-- | libdocument/ev-file-helpers.c | 37 |
1 files changed, 37 insertions, 0 deletions
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, |