From 900a6564203b69851cf43fc87eb7190c82acec38 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 31 Jul 2008 18:23:17 +0000 Subject: * refactor: rearrange path inventory manipulation so that input tidying can be used for item paths as well --- OpenSim/Region/Application/OpenSimBase.cs | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Application/OpenSimBase.cs') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 0d471d8..828abcb 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -698,27 +698,37 @@ namespace OpenSim } InventoryFolderImpl inventoryFolder = null; + //InventoryItemBase inventoryItem = null; if (userInfo.HasReceivedInventory) { - if (invPath == InventoryFolderImpl.PATH_DELIMITER) + // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl + // itself (possibly at a small loss in efficiency). + string[] components + = invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); + invPath = String.Empty; + foreach (string c in components) + { + invPath += c + InventoryFolderImpl.PATH_DELIMITER; + } + + invPath = invPath.Remove(invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); + + // Annoyingly Split actually returns the original string if the input string consists only of delimiters + // Therefore if we still start with a / after the split, then we need the root folder + if (invPath.StartsWith(InventoryFolderImpl.PATH_DELIMITER)) { inventoryFolder = userInfo.RootFolder; } else - { - // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl - // itself (possibly at a small loss in efficiency). - string[] components - = invPath.Split(new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); - invPath = String.Empty; - foreach (string c in components) - { - invPath += c + InventoryFolderImpl.PATH_DELIMITER; - } + { + inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath); + } - inventoryFolder = userInfo.RootFolder.FindFolderByPath(invPath); - } +// if (inventoryFolder == null) +// { +// +// } } else { -- cgit v1.1