2 * Copyright 2015 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the licence, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 * Author: Matthias Clasen <mclasen@redhat.com>
28 static gboolean force
= FALSE
;
30 static const GOptionEntry entries
[] = {
31 {"force", 'f', 0, G_OPTION_ARG_NONE
, &force
, N_("Ignore nonexistent files, never prompt"), NULL
},
36 handle_remove (int argc
, char *argv
[], gboolean do_help
)
38 GOptionContext
*context
;
45 g_set_prgname ("gio remove");
47 /* Translators: commandline placeholder */
48 param
= g_strdup_printf ("%s...", _("LOCATION"));
49 context
= g_option_context_new (param
);
51 g_option_context_set_help_enabled (context
, FALSE
);
52 g_option_context_set_summary (context
, _("Delete the given files."));
53 g_option_context_add_main_entries (context
, entries
, GETTEXT_PACKAGE
);
57 show_help (context
, NULL
);
61 if (!g_option_context_parse (context
, &argc
, &argv
, &error
))
63 show_help (context
, error
->message
);
70 show_help (context
, _("No files to delete"));
74 g_option_context_free (context
);
77 for (i
= 1; i
< argc
; i
++)
79 file
= g_file_new_for_commandline_arg (argv
[i
]);
80 if (!g_file_delete (file
, NULL
, &error
))
83 !g_error_matches (error
, G_IO_ERROR
, G_IO_ERROR_NOT_FOUND
))
85 print_file_error (file
, error
->message
);
88 g_clear_error (&error
);
90 g_object_unref (file
);