summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-08-24 16:25:04 +0200
committerAlexander Larsson <alexl@redhat.com>2009-08-24 16:25:04 +0200
commitf20369496be7bdb7a614916367c6d4fd459dd44a (patch)
treee63287668f905cbb61e86ab854e0aaef8423e66c
parent8b1d6c56990d2cad60a042065df8947bc104f096 (diff)
downloadgvfs-f20369496be7bdb7a614916367c6d4fd459dd44a.tar.gz
Add -f support to gvfs-rm and gvfs-trash
Also clean up things a bit, and fix up translations.
-rw-r--r--programs/gvfs-rm.c25
-rw-r--r--programs/gvfs-trash.c25
2 files changed, 31 insertions, 19 deletions
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 <glib.h>
#include <locale.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
-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);
diff --git a/programs/gvfs-trash.c b/programs/gvfs-trash.c
index 7fa1aecd..d8689a49 100644
--- a/programs/gvfs-trash.c
+++ b/programs/gvfs-trash.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,42 +24,47 @@
#include <glib.h>
#include <locale.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
+static gboolean force = FALSE;
-static GOptionEntry entries[] =
+static GOptionEntry entries[] =
{
- { NULL }
+ {"force", 'f', 0, G_OPTION_ARG_NONE, &force,
+ N_("ignore nonexistent files, never prompt"), NULL},
+ { NULL }
};
-
int
main (int argc, char *argv[])
{
GError *error;
GOptionContext *context;
GFile *file;
-
+
setlocale (LC_ALL, "");
g_type_init ();
-
+
error = NULL;
- context = g_option_context_new ("- move files to trash");
+ context = g_option_context_new (_("- move files to trash"));
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_trash (file, NULL, &error))
{
- g_print ("Error trashing file: %s\n", error->message);
+ if (!force ||
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ g_printerr (_("Error trashing file: %s\n"), error->message);
g_error_free (error);
}
g_object_unref (file);