1 | /* gnomevfs-copy.c - Test for open(), read() and write() for gnome-vfs |
---|
2 | |
---|
3 | Copyright (C) 2003, Red Hat |
---|
4 | |
---|
5 | The Gnome Library is free software; you can redistribute it and/or |
---|
6 | modify it under the terms of the GNU Library General Public License as |
---|
7 | published by the Free Software Foundation; either version 2 of the |
---|
8 | License, or (at your option) any later version. |
---|
9 | |
---|
10 | The Gnome Library is distributed in the hope that it will be useful, |
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | Library General Public License for more details. |
---|
14 | |
---|
15 | You should have received a copy of the GNU Library General Public |
---|
16 | License along with the Gnome Library; see the file COPYING.LIB. If not, |
---|
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
18 | Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | Author: Bastien Nocera <hadess@hadess.net> |
---|
21 | */ |
---|
22 | |
---|
23 | #include <libgnomevfs/gnome-vfs.h> |
---|
24 | |
---|
25 | #include <stdio.h> |
---|
26 | #include <stdlib.h> |
---|
27 | #include <unistd.h> |
---|
28 | |
---|
29 | /* Copied directly from eel */ |
---|
30 | static GnomeVFSResult |
---|
31 | copy_uri_simple ( const char *source_uri, const char *dest_uri) |
---|
32 | { |
---|
33 | GnomeVFSResult result; |
---|
34 | GnomeVFSURI *real_source_uri, *real_dest_uri; |
---|
35 | real_source_uri = gnome_vfs_uri_new (source_uri); |
---|
36 | real_dest_uri = gnome_vfs_uri_new (dest_uri); |
---|
37 | |
---|
38 | result = gnome_vfs_xfer_uri (real_source_uri, real_dest_uri, |
---|
39 | GNOME_VFS_XFER_RECURSIVE, |
---|
40 | GNOME_VFS_XFER_ERROR_MODE_ABORT, |
---|
41 | GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE, |
---|
42 | NULL, NULL); |
---|
43 | |
---|
44 | gnome_vfs_uri_unref (real_source_uri); |
---|
45 | gnome_vfs_uri_unref (real_dest_uri); |
---|
46 | |
---|
47 | return result; |
---|
48 | } |
---|
49 | |
---|
50 | int |
---|
51 | main (int argc, char **argv) |
---|
52 | { |
---|
53 | GnomeVFSResult res; |
---|
54 | |
---|
55 | if (argc != 3) { |
---|
56 | printf ("Usage: %s <src> <dest>\n", argv[0]); |
---|
57 | return 1; |
---|
58 | } |
---|
59 | |
---|
60 | if (!gnome_vfs_init ()) { |
---|
61 | fprintf (stderr, "Cannot initialize gnome-vfs.\n"); |
---|
62 | return 1; |
---|
63 | } |
---|
64 | |
---|
65 | res = copy_uri_simple (argv[1], argv[2]); |
---|
66 | |
---|
67 | if (res != GNOME_VFS_OK) { |
---|
68 | fprintf (stderr, "Failed to copy %s to %s\nReason: %s\n", |
---|
69 | argv[1], argv[2], gnome_vfs_result_to_string (res)); |
---|
70 | return 1; |
---|
71 | } |
---|
72 | |
---|
73 | return 0; |
---|
74 | } |
---|