From f20369496be7bdb7a614916367c6d4fd459dd44a Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 24 Aug 2009 16:25:04 +0200 Subject: Add -f support to gvfs-rm and gvfs-trash Also clean up things a bit, and fix up translations. --- programs/gvfs-rm.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'programs/gvfs-rm.c') diff --git a/programs/gvfs-rm.c b/programs/gvfs-rm.c index cb666549..85f4fa04 100644 --- a/programs/gvfs-rm.c +++ b/programs/gvfs-rm.c @@ -1,5 +1,5 @@ /* GIO - GLib Input, Output and Streaming Library - * + * * Copyright (C) 2006-2007 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -24,11 +24,16 @@ #include #include +#include #include -static GOptionEntry entries[] = +static gboolean force = FALSE; + +static GOptionEntry entries[] = { - { NULL } + {"force", 'f', 0, G_OPTION_ARG_NONE, &force, + N_("ignore nonexistent files, never prompt"), NULL}, + { NULL } }; @@ -38,27 +43,29 @@ main (int argc, char *argv[]) GError *error; GOptionContext *context; GFile *file; - + setlocale (LC_ALL, ""); g_type_init (); - + error = NULL; - context = g_option_context_new ("- delete files"); + context = g_option_context_new (_("- delete files")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); - + if (argc > 1) { int i; - + for (i = 1; i < argc; i++) { file = g_file_new_for_commandline_arg (argv[i]); error = NULL; if (!g_file_delete (file, NULL, &error)) { - g_print ("Error deleting file: %s\n", error->message); + if (!force || + !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) + g_printerr ("Error deleting file: %s\n", error->message); g_error_free (error); } g_object_unref (file); -- cgit v1.2.1