3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
using System.Collections.Generic;
27
namespace FilePlugin {
28
class CopyToAction : IAction {
30
public string Name { get { return "Copy to..."; } }
31
public string Description { get { return "Copies a file or folder to another location."; } }
32
public string Icon { get { return "gtk-copy"; } }
34
public Type [] SupportedItemTypes {
42
public Type [] SupportedModifierItemTypes {
50
public bool ModifierItemsOptional {
54
public bool SupportsItem (IItem item)
59
public bool SupportsModifierItemForItems (IItem [] items, IItem modItem)
61
return FileItem.IsDirectory (modItem as IFileItem);
64
public IItem [] DynamicModifierItemsForItem (IItem item)
69
public IItem [] Perform (IItem [] items, IItem [] modItems)
72
List<string> seenPaths;
74
dest = modItems [0] as IFileItem;
75
seenPaths = new List<string> ();
76
foreach (FileItem src in items) {
77
if (seenPaths.Contains (src.Path)) continue;
79
File.Copy (FileItem.EscapedPath (src),
80
FileItem.EscapedPath (dest) + "/" + src.Name);
81
//System.Diagnostics.Process.Start ("cp",
82
// string.Format ("-r {0} {1}",
83
// FileItem.EscapedPath (src), FileItem.EscapedPath (dest)));
85
seenPaths.Add (src.Path);
86
src.Path = Path.Combine (dest.Path, Path.GetFileName (src.Path));
87
} catch (Exception e) {
88
Console.Error.WriteLine ("CopyToAction could not copy "+
89
src.Path + " to " + dest.Path + ": " + e.Message);
b'\\ No newline at end of file'