From 1b5c624975ff3042d3f99b97c2e34c53584a7f02 Mon Sep 17 00:00:00 2001
From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com>
Date: Mon, 28 Nov 2005 02:13:23 +0000
Subject: [PATCH] r1128@localhost: muntyan | 2005-11-27 14:12:07 -0600
Implemented copy/move/link
---
moo.kdevelop | 18 +++----
moo/mooutils/Makefile.incl | 2 +
moo/mooutils/moofileview/moofileview.c | 68 ++++++++++++++++++++++++--
3 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/moo.kdevelop b/moo.kdevelop
index 7cf7416f..3202c46a 100644
--- a/moo.kdevelop
+++ b/moo.kdevelop
@@ -24,7 +24,7 @@
.
false
-
+
C
@@ -39,7 +39,7 @@
./medit
executable
/
-
+
false
false
@@ -190,7 +190,7 @@
true
- 3
+ 1
false
0
@@ -198,12 +198,12 @@
-
+
--g-fatal-warnings
-
-
-
-
+
+
+
+
true
false
true
@@ -304,7 +304,7 @@
-
+
set
m_,_
theValue
diff --git a/moo/mooutils/Makefile.incl b/moo/mooutils/Makefile.incl
index d341253f..6ae8bed1 100644
--- a/moo/mooutils/Makefile.incl
+++ b/moo/mooutils/Makefile.incl
@@ -218,6 +218,7 @@ mooutils_include_headers = \
$(mooutils)/moobigpaned.h \
$(mooutils)/moocellrenderercolor.h \
$(mooutils)/mooclosure.h \
+ $(mooutils)/moocmd.h \
$(mooutils)/moocombo.h \
$(mooutils)/mooentry.h \
$(mooutils)/moofiltermgr.h \
@@ -254,6 +255,7 @@ mooutils_sources = \
$(mooutils)/moobigpaned.c \
$(mooutils)/moocellrenderercolor.c \
$(mooutils)/mooclosure.c \
+ $(mooutils)/moocmd.c \
$(mooutils)/moocombo.c \
$(mooutils)/moocompat.c \
$(mooutils)/moocompat.h \
diff --git a/moo/mooutils/moofileview/moofileview.c b/moo/mooutils/moofileview/moofileview.c
index 638021d7..5e77c346 100644
--- a/moo/mooutils/moofileview/moofileview.c
+++ b/moo/mooutils/moofileview/moofileview.c
@@ -34,6 +34,7 @@
#include "mooutils/moofiltermgr.h"
#include "mooutils/mootoggleaction.h"
#include "mooutils/moouixml.h"
+#include "mooutils/moocmd.h"
#include MOO_MARSHALS_H
#include
#include
@@ -4650,12 +4651,69 @@ sync_dest_targets (MooFileView *fileview)
/* Dropping stuff
*/
+static void
+run_command_on_files (MooFileView *fileview,
+ GSList *filenames,
+ const char *destdir,
+ const char **first_args,
+ int n_first_args)
+{
+ GError *error = NULL;
+ MooCmd *cmd;
+ char **argv;
+ int list_len, n_args, i;
+ GSList *l;
+
+ g_return_if_fail (filenames != NULL);
+ g_return_if_fail (destdir != NULL);
+ g_return_if_fail (n_first_args > 0);
+
+ list_len = g_slist_length (filenames);
+
+ n_args = list_len + n_first_args + 1;
+ argv = g_new (char*, n_args + 1);
+
+ for (i = 0; i < n_first_args; ++i)
+ {
+ g_assert (first_args[i] != NULL);
+ argv[i] = (char*) first_args[i];
+ }
+
+ argv[n_args-1] = (char*) destdir;
+ argv[n_args] = NULL;
+
+ for (i = 0, l = filenames; l != NULL; l = l->next, i++)
+ argv[n_first_args + i] = l->data;
+
+ cmd = moo_cmd_new_full (NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH,
+ MOO_CMD_STDOUT_TO_PARENT | MOO_CMD_STDERR_TO_PARENT,
+ NULL, NULL, &error);
+
+ if (!cmd)
+ {
+ g_critical ("%s: could not spawn '%s'",
+ G_STRLOC, first_args[0]);
+ g_critical ("%s: %s", G_STRLOC, error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ g_signal_connect (cmd, "cmd-exit", G_CALLBACK (g_object_unref), NULL);
+
+out:
+ g_free (argv);
+}
+
+
static void
copy_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
- g_print ("copy-copy\n");
+ const char *args[] = {"cp", "-R", "--"};
+ run_command_on_files (fileview, filenames, destdir,
+ args, G_N_ELEMENTS (args));
}
@@ -4664,7 +4722,9 @@ move_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
- g_print ("move-move\n");
+ const char *args[] = {"mv", "--"};
+ run_command_on_files (fileview, filenames, destdir,
+ args, G_N_ELEMENTS (args));
}
@@ -4673,7 +4733,9 @@ link_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
- g_print ("link-link\n");
+ const char *args[] = {"ln", "-s", "--"};
+ run_command_on_files (fileview, filenames, destdir,
+ args, G_N_ELEMENTS (args));
}