2007-04-28 20:54:02 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Xml.Serialization;
|
2008-07-21 21:12:59 +00:00
|
|
|
using OpenMetaverse;
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2008-07-16 02:37:23 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Inventory Example, Moves a folder to the Trash folder
|
|
|
|
|
/// </summary>
|
2007-04-28 20:54:02 +00:00
|
|
|
public class DeleteFolderCommand : Command
|
|
|
|
|
{
|
|
|
|
|
public DeleteFolderCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "deleteFolder";
|
2008-07-16 02:37:23 +00:00
|
|
|
Description = "Moves a folder to the Trash Folder";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Inventory;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2008-07-16 02:37:23 +00:00
|
|
|
// parse the command line
|
|
|
|
|
string target = String.Empty;
|
|
|
|
|
for (int ct = 0; ct < args.Length; ct++)
|
|
|
|
|
target = target + args[ct] + " ";
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2008-07-16 02:37:23 +00:00
|
|
|
// initialize results list
|
|
|
|
|
List<InventoryBase> found = new List<InventoryBase>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// find the folder
|
2008-08-12 05:55:42 +00:00
|
|
|
|
|
|
|
|
found = Client.InventoryStore.InventoryFromPath(target, Client.CurrentDirectory, true);
|
2008-07-29 21:36:53 +00:00
|
|
|
if (found.Count > 0)
|
2008-07-16 02:37:23 +00:00
|
|
|
{
|
2008-07-29 21:36:53 +00:00
|
|
|
InventoryBase item = found[0];
|
|
|
|
|
InventoryFolder trash = Client.InventoryStore[Client.Inventory.FindFolderForType(AssetType.TrashFolder)] as InventoryFolder;
|
|
|
|
|
if (trash != null)
|
|
|
|
|
{
|
|
|
|
|
item.Move(trash);
|
|
|
|
|
return String.Format("Moved folder {0} ({1}) to Trash", item.Name, item.UUID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return String.Format("Unable to locate {0}", target);
|
2008-07-16 02:37:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (InvalidOutfitException ex)
|
|
|
|
|
{
|
|
|
|
|
return "Folder Not Found: (" + ex.Message + ")";
|
|
|
|
|
}
|
|
|
|
|
return string.Empty;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-07-29 21:36:53 +00:00
|
|
|
}
|