diff options
author | Jani Monoses <jani.monoses@gmail.com> | 2006-01-19 15:12:56 (GMT) |
---|---|---|
committer | Nickolay V. Shmyrev <nshmyrev@src.gnome.org> | 2006-01-19 15:12:56 (GMT) |
commit | f693b48e9ca24fec37c190cdb90682c67e8e6c28 (patch) | |
tree | 9e50f7840a43707fcc82a32e5707480228588c3f /lib/ev-file-helpers.c | |
parent | 4f7cfb63f1edc6bf5ceee1673ca916ff85860a8f (diff) |
Use common save function for backends.
2006-01-19 Jani Monoses <jani.monoses@gmail.com>
* comics/comics-document.c: (comics_document_save):
* djvu/djvu-document.c: (djvu_document_save):
* dvi/dvi-document.c: (dvi_document_save):
* lib/ev-file-helpers.c: (ev_tmp_filename), (ev_xfer_uri_simple):
* lib/ev-file-helpers.h:
* pixbuf/pixbuf-document.c: (pixbuf_document_save):
* tiff/tiff-document.c: (tiff_document_save):
Use common save function for backends.
Diffstat (limited to 'lib/ev-file-helpers.c')
-rw-r--r-- | lib/ev-file-helpers.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/ev-file-helpers.c b/lib/ev-file-helpers.c index 247e511..130c62b 100644 --- a/lib/ev-file-helpers.c +++ b/lib/ev-file-helpers.c @@ -23,9 +23,13 @@ #endif #include <sys/stat.h> +#include <unistd.h> #include <glib.h> #include <libgnome/gnome-init.h> -#include <unistd.h> +#include <libgnomevfs/gnome-vfs-uri.h> +#include <libgnomevfs/gnome-vfs-utils.h> +#include <libgnomevfs/gnome-vfs-ops.h> +#include <libgnomevfs/gnome-vfs-xfer.h> #include "ev-file-helpers.h" @@ -124,3 +128,36 @@ ev_tmp_filename (void) return filename; } + +gboolean +ev_xfer_uri_simple (const char *from, + const char *to, + GError **error) +{ + GnomeVFSResult result; + GnomeVFSURI *source_uri; + GnomeVFSURI *target_uri; + + if (!from) + return FALSE; + + source_uri = gnome_vfs_uri_new (from); + target_uri = gnome_vfs_uri_new (to); + + result = gnome_vfs_xfer_uri (source_uri, target_uri, + GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS, + GNOME_VFS_XFER_ERROR_MODE_ABORT, + GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, + NULL, + NULL); + gnome_vfs_uri_unref (target_uri); + gnome_vfs_uri_unref (source_uri); + + if (result != GNOME_VFS_OK) + g_set_error (error, + G_FILE_ERROR, + G_FILE_ERROR_FAILED, + gnome_vfs_result_to_string (result)); + return (result == GNOME_VFS_OK); + +} |