#include <libgnomevfs/gnome-vfs.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	GnomeVFSURI *src, *dst;
	GnomeVFSResult result;
	gchar *from, *to;

	if(argc != 3)
	{
		fprintf(stderr, "Error: Not enough arguments!\n");
		return 1;
	}

	gnome_vfs_init ();

	from = gnome_vfs_make_uri_from_shell_arg (argv[1]);
	to = gnome_vfs_make_uri_from_shell_arg (argv[2]);

	src = gnome_vfs_uri_new (from);
	dst = gnome_vfs_uri_new (to);

	if(src == NULL || dst == NULL)
	{
		fprintf(stderr, "Error: Could not create URIs!\n");
		g_free(from);
		g_free(to);
		return 2;
	}

	g_free (from);
	g_free (to);

	result = gnome_vfs_xfer_uri (src,
				     dst,
				     GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS | GNOME_VFS_XFER_FOLLOW_LINKS_RECURSIVE,
				     GNOME_VFS_XFER_ERROR_MODE_ABORT,
				     GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
				     NULL,
				     NULL);
	
	if (result != GNOME_VFS_OK)
		fprintf(stderr, "XFER-Error: %s\n", gnome_vfs_result_to_string(result));

	gnome_vfs_uri_unref(src);
	gnome_vfs_uri_unref(dst);


	return ((result == GNOME_VFS_OK) ? 0 : 3);
}
