[18316] | 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
---|
| 2 | /* test-unlink.c - Test program for unlink operation in the GNOME |
---|
| 3 | Virtual File System. |
---|
| 4 | |
---|
| 5 | Copyright (C) 1999 Free Software Foundation |
---|
| 6 | Copyright (C) 2000 Eazel Inc. |
---|
| 7 | |
---|
| 8 | The Gnome Library is free software; you can redistribute it and/or |
---|
| 9 | modify it under the terms of the GNU Library General Public License as |
---|
| 10 | published by the Free Software Foundation; either version 2 of the |
---|
| 11 | License, or (at your option) any later version. |
---|
| 12 | |
---|
| 13 | The Gnome Library is distributed in the hope that it will be useful, |
---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | Library General Public License for more details. |
---|
| 17 | |
---|
| 18 | You should have received a copy of the GNU Library General Public |
---|
| 19 | License along with the Gnome Library; see the file COPYING.LIB. If not, |
---|
| 20 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
| 21 | Boston, MA 02111-1307, USA. |
---|
| 22 | |
---|
| 23 | Authors: |
---|
| 24 | Ettore Perazzoli <ettore@gnu.org> |
---|
| 25 | Ian McKellar <yakk@yakk.net.au> |
---|
| 26 | */ |
---|
| 27 | |
---|
| 28 | #include <config.h> |
---|
| 29 | |
---|
| 30 | #include <libgnomevfs/gnome-vfs-init.h> |
---|
| 31 | #include <libgnomevfs/gnome-vfs-ops.h> |
---|
| 32 | #include <stdio.h> |
---|
| 33 | #include <stdlib.h> |
---|
| 34 | #include <unistd.h> |
---|
| 35 | |
---|
| 36 | static void |
---|
| 37 | show_result (GnomeVFSResult result, const gchar *what, const gchar *text_uri) |
---|
| 38 | { |
---|
| 39 | fprintf (stderr, "%s `%s': %s\n", |
---|
| 40 | what, text_uri, gnome_vfs_result_to_string (result)); |
---|
| 41 | if (result != GNOME_VFS_OK) |
---|
| 42 | exit (1); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | int |
---|
| 46 | main (int argc, char **argv) |
---|
| 47 | { |
---|
| 48 | GnomeVFSResult result; |
---|
| 49 | GnomeVFSURI *uri; |
---|
| 50 | gchar *text_uri; |
---|
| 51 | |
---|
| 52 | if (argc != 2) { |
---|
| 53 | printf ("Usage: %s <uri>\n", argv[0]); |
---|
| 54 | return 1; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | if (! gnome_vfs_init ()) { |
---|
| 58 | fprintf (stderr, "Cannot initialize gnome-vfs.\n"); |
---|
| 59 | return 1; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | uri = gnome_vfs_uri_new (argv[1]); |
---|
| 63 | if (uri == NULL) { |
---|
| 64 | fprintf (stderr, "URI not valid.\n"); |
---|
| 65 | return 1; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); |
---|
| 69 | |
---|
| 70 | result = gnome_vfs_unlink (text_uri); |
---|
| 71 | show_result (result, "unlink", text_uri); |
---|
| 72 | |
---|
| 73 | g_free (text_uri); |
---|
| 74 | |
---|
| 75 | return 0; |
---|
| 76 | } |
---|