source: trunk/third/gnome-vfs2/programs/gnomevfs-rm.c @ 20794

Revision 20794, 1.9 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20793, which included commits to RCS files with non-trunk default branches.
Line 
1/* gnomevfs-rm.c - Test for unlink() for gnome-vfs
2
3   Copyright (C) 1999 Free Software Foundation
4   Copyright (C) 2003, Red Hat
5
6   The Gnome Library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Library General Public License as
8   published by the Free Software Foundation; either version 2 of the
9   License, or (at your option) any later version.
10
11   The Gnome Library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Library General Public License for more details.
15
16   You should have received a copy of the GNU Library General Public
17   License along with the Gnome Library; see the file COPYING.LIB.  If not,
18   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA.
20
21   Author: Ettore Perazzoli <ettore@gnu.org>
22           Bastien Nocera <hadess@hadess.net>
23*/
24
25#include <libgnomevfs/gnome-vfs.h>
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <unistd.h>
30
31static void
32show_result (GnomeVFSResult result, const gchar *what, const gchar *text_uri)
33{
34        if (result != GNOME_VFS_OK) {
35                fprintf (stderr, "%s `%s': %s\n",
36                                what, text_uri,
37                                gnome_vfs_result_to_string (result));
38                exit (1);
39        }
40}
41
42int
43main (int argc, char **argv)
44{
45        GnomeVFSResult    result;
46        GnomeVFSURI      *uri;
47        gchar            *text_uri;
48
49        if (argc != 2) {
50                fprintf (stderr, "Usage: %s <uri>\n", argv[0]);
51                return 1;
52        }
53
54        if (! gnome_vfs_init ()) {
55                fprintf (stderr, "Cannot initialize gnome-vfs.\n");
56                return 1;
57        }
58
59        uri = gnome_vfs_uri_new (argv[1]);
60        if (uri == NULL) {
61                fprintf (stderr, "URI %s not valid.\n", argv[1]);
62                return 1;
63        }
64
65        text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
66
67        result = gnome_vfs_unlink_from_uri (uri);
68        show_result (result, "open", text_uri);
69
70        g_free (text_uri);
71
72        return 0;
73}
74
Note: See TracBrowser for help on using the repository browser.