aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index 6d598d1..2eeb637 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
31using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
32 33
@@ -38,6 +39,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
38 public static class InventoryArchiveUtils 39 public static class InventoryArchiveUtils
39 { 40 {
40 public static readonly string PATH_DELIMITER = "/"; 41 public static readonly string PATH_DELIMITER = "/";
42
43 /// <summary>
44 /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder
45 /// </summary>
46 ///
47 /// This method does not handle paths that contain multiple delimitors
48 ///
49 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some
50 /// XPath like expression
51 ///
52 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
53 ///
54 /// <param name="inventoryService">
55 /// Inventory service to query
56 /// </param>
57 /// <param name="userId">
58 /// User id to search
59 /// </param>
60 /// <param name="path">
61 /// The path to the required folder.
62 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
63 /// </param>
64 /// <returns>null if the folder is not found</returns>
65 public static InventoryFolderBase FindFolderByPath(
66 IInventoryService inventoryService, UUID userId, string path)
67 {
68 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
69
70 if (null == rootFolder)
71 return null;
72
73 return FindFolderByPath(inventoryService, rootFolder, path);
74 }
41 75
42 /// <summary> 76 /// <summary>
43 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder 77 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder
@@ -91,6 +125,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 // We didn't find a folder with the right name 125 // We didn't find a folder with the right name
92 return null; 126 return null;
93 } 127 }
128
129 /// <summary>
130 /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder.
131 ///
132 /// This method does not handle paths that contain multiple delimitors
133 ///
134 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
135 /// XPath like expression
136 ///
137 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
138 /// </summary>
139 ///
140 /// <param name="inventoryService">
141 /// Inventory service to query
142 /// </param>
143 /// <param name="userId">
144 /// The user to search
145 /// </param>
146 /// <param name="path">
147 /// The path to the required item.
148 /// </param>
149 /// <returns>null if the item is not found</returns>
150 public static InventoryItemBase FindItemByPath(
151 IInventoryService inventoryService, UUID userId, string path)
152 {
153 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
154
155 if (null == rootFolder)
156 return null;
157
158 return FindItemByPath(inventoryService, rootFolder, path);
159 }
94 160
95 /// <summary> 161 /// <summary>
96 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. 162 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.