aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-07-31 18:23:17 +0000
committerJustin Clarke Casey2008-07-31 18:23:17 +0000
commit900a6564203b69851cf43fc87eb7190c82acec38 (patch)
tree2d2fcc2735003b55b7f2b0846ab28339d5726411 /OpenSim/Framework
parent* refactor: eliminate unused SubFoldersCount (diff)
downloadopensim-SC-900a6564203b69851cf43fc87eb7190c82acec38.zip
opensim-SC-900a6564203b69851cf43fc87eb7190c82acec38.tar.gz
opensim-SC-900a6564203b69851cf43fc87eb7190c82acec38.tar.bz2
opensim-SC-900a6564203b69851cf43fc87eb7190c82acec38.tar.xz
* refactor: rearrange path inventory manipulation so that input tidying can be used for item paths as well
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs55
1 files changed, 50 insertions, 5 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index ee3fc55..96853f0 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache
108 } 108 }
109 109
110 /// <summary> 110 /// <summary>
111 /// Returns the item if it exists in this folder or any of this folder's subfolders? 111 /// Returns the item if it exists in this folder or in any of this folder's descendant folders
112 /// </summary> 112 /// </summary>
113 /// <param name="itemID"></param> 113 /// <param name="itemID"></param>
114 /// <returns>null if the item is not found</returns> 114 /// <returns>null if the item is not found</returns>
@@ -197,7 +197,7 @@ namespace OpenSim.Framework.Communications.Cache
197 } 197 }
198 198
199 /// <summary> 199 /// <summary>
200 /// Find a folder given a PATH_DELIMITOR delimited path. 200 /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder
201 /// 201 ///
202 /// This method does not handle paths that contain multiple delimitors 202 /// This method does not handle paths that contain multiple delimitors
203 /// 203 ///
@@ -208,9 +208,8 @@ namespace OpenSim.Framework.Communications.Cache
208 /// </summary> 208 /// </summary>
209 /// <param name="path"> 209 /// <param name="path">
210 /// The path to the required folder. It this is empty then this folder itself is returned. 210 /// The path to the required folder. It this is empty then this folder itself is returned.
211 /// If a folder for the given path is not found, then null is returned.
212 /// </param> 211 /// </param>
213 /// <returns></returns> 212 /// <returns>null if the folder is not found</returns>
214 public InventoryFolderImpl FindFolderByPath(string path) 213 public InventoryFolderImpl FindFolderByPath(string path)
215 { 214 {
216 if (path == string.Empty) 215 if (path == string.Empty)
@@ -234,6 +233,52 @@ namespace OpenSim.Framework.Communications.Cache
234 // We didn't find a folder with the given name 233 // We didn't find a folder with the given name
235 return null; 234 return null;
236 } 235 }
236
237 /// <summary>
238 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
239 ///
240 /// This method does not handle paths that contain multiple delimitors
241 ///
242 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
243 /// XPath like expression
244 ///
245 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
246 /// </summary>
247 /// <param name="path">
248 /// The path to the required item.
249 /// </param>
250 /// <returns>null if the item is not found</returns>
251 public InventoryItemBase FindItemByPath(string path)
252 {
253 int delimitorIndex = path.IndexOf(PATH_DELIMITER);
254 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
255
256 if (components.Length == 1)
257 {
258 lock (Items)
259 {
260 foreach (InventoryItemBase item in Items.Values)
261 {
262 if (item.Name == components[0])
263 return item;
264 }
265 }
266 }
267 else
268 {
269 lock (SubFolders)
270 {
271 foreach (InventoryFolderImpl folder in SubFolders.Values)
272 {
273 if (folder.Name == components[0])
274 return folder.FindItemByPath(components[1]);
275 }
276 }
277 }
278
279 // We didn't find an item or intermediate folder with the given name
280 return null;
281 }
237 282
238 /// <summary> 283 /// <summary>
239 /// Return a copy of the list of child items in this folder 284 /// Return a copy of the list of child items in this folder
@@ -256,7 +301,7 @@ namespace OpenSim.Framework.Communications.Cache
256 } 301 }
257 302
258 /// <summary> 303 /// <summary>
259 /// Return a copy of the list of immediate child folders in this folder. 304 /// Return a copy of the list of child folders in this folder.
260 /// </summary> 305 /// </summary>
261 public List<InventoryFolderBase> RequestListOfFolders() 306 public List<InventoryFolderBase> RequestListOfFolders()
262 { 307 {