LIBOMV-359 Reverting InventoryManager/Inventory system to old inventory system based on r2020, Disabled GUI library in prebuild.xml as its based on the new inventory system and needs to be rewritten to be used with the old inventorymanager (or re-enabled when new inventory system is added back to trunk
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2126 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -19,34 +19,68 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell
|
||||
public override string Execute(string[] args, UUID fromAgentID)
|
||||
{
|
||||
Manager = Client.Inventory;
|
||||
Inventory = Client.InventoryStore;
|
||||
Inventory = Client.Inventory.Store;
|
||||
|
||||
if (args.Length > 1)
|
||||
return "Usage: cd [path-to-folder]";
|
||||
string pathStr = "";
|
||||
string[] path = null;
|
||||
if (args.Length == 0)
|
||||
return "Current folder: " + Client.CurrentDirectory.Name;
|
||||
|
||||
string path = args[0];
|
||||
for(int i = 1; i < args.Length; ++i)
|
||||
{
|
||||
path += " " + args[i];
|
||||
path = new string[] { "" };
|
||||
// cd without any arguments doesn't do anything.
|
||||
}
|
||||
|
||||
List<InventoryBase> results = Inventory.InventoryFromPath(path, Client.CurrentDirectory, true);
|
||||
if (results.Count == 0)
|
||||
return "Can not find inventory at: " + path;
|
||||
InventoryFolder destFolder = null;
|
||||
foreach (InventoryBase ib in results)
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
if (ib is InventoryFolder)
|
||||
pathStr = args[0];
|
||||
path = pathStr.Split(new char[] { '/' });
|
||||
// Use '/' as a path seperator.
|
||||
}
|
||||
InventoryFolder currentFolder = Client.CurrentDirectory;
|
||||
if (pathStr.StartsWith("/"))
|
||||
currentFolder = Inventory.RootFolder;
|
||||
|
||||
if (currentFolder == null) // We need this to be set to something.
|
||||
return "Error: Client not logged in.";
|
||||
|
||||
// Traverse the path, looking for the
|
||||
for (int i = 0; i < path.Length; ++i)
|
||||
{
|
||||
string nextName = path[i];
|
||||
if (string.IsNullOrEmpty(nextName) || nextName == ".")
|
||||
continue; // Ignore '.' and blanks, stay in the current directory.
|
||||
if (nextName == ".." && currentFolder != Inventory.RootFolder)
|
||||
{
|
||||
destFolder = ib as InventoryFolder;
|
||||
break;
|
||||
// If we encounter .., move to the parent folder.
|
||||
currentFolder = Inventory[currentFolder.ParentUUID] as InventoryFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<InventoryBase> currentContents = Inventory.GetContents(currentFolder);
|
||||
// Try and find an InventoryBase with the corresponding name.
|
||||
bool found = false;
|
||||
foreach (InventoryBase item in currentContents)
|
||||
{
|
||||
// Allow lookup by UUID as well as name:
|
||||
if (item.Name == nextName || item.UUID.ToString() == nextName)
|
||||
{
|
||||
found = true;
|
||||
if (item is InventoryFolder)
|
||||
{
|
||||
currentFolder = item as InventoryFolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
return item.Name + " is not a folder.";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
return nextName + " not found in " + currentFolder.Name;
|
||||
}
|
||||
}
|
||||
if (destFolder == null)
|
||||
return path + " is not a folder.";
|
||||
|
||||
Client.CurrentDirectory = destFolder;
|
||||
return "Current folder: " + Client.CurrentDirectory.Name;
|
||||
Client.CurrentDirectory = currentFolder;
|
||||
return "Current folder: " + currentFolder.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user