diff options
author | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
commit | 0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae (patch) | |
tree | dfcf0200f8b8661635914a97d6162714aa143e90 /OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | |
parent | * Add ability to defer item actions for AddItem() and DeleteItem(). This won... (diff) | |
download | opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.zip opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.gz opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.bz2 opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.xz |
* Simplify CreateFolder() by folding previous special root case into FindFolder()
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index af05af3..c8cec69 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
69 | /// <param name="folderName"></param> | 69 | /// <param name="folderName"></param> |
70 | /// <param name="type"></param> | 70 | /// <param name="type"></param> |
71 | /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> | 71 | /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> |
72 | public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) | 72 | public InventoryFolderImpl CreateChildFolder(LLUUID folderID, string folderName, ushort type) |
73 | { | 73 | { |
74 | lock (SubFolders) | 74 | lock (SubFolders) |
75 | { | 75 | { |
@@ -82,6 +82,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
82 | subFold.ParentID = this.ID; | 82 | subFold.ParentID = this.ID; |
83 | subFold.Owner = Owner; | 83 | subFold.Owner = Owner; |
84 | SubFolders.Add(subFold.ID, subFold); | 84 | SubFolders.Add(subFold.ID, subFold); |
85 | |||
85 | return subFold; | 86 | return subFold; |
86 | } | 87 | } |
87 | } | 88 | } |
@@ -135,7 +136,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
135 | } | 136 | } |
136 | 137 | ||
137 | /// <summary> | 138 | /// <summary> |
138 | /// Delete an item from the folder. | 139 | /// Deletes an item if it exists in this folder or any children |
139 | /// </summary> | 140 | /// </summary> |
140 | /// <param name="folderID"></param> | 141 | /// <param name="folderID"></param> |
141 | /// <returns></returns> | 142 | /// <returns></returns> |
@@ -157,6 +158,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
157 | foreach (InventoryFolderImpl folder in SubFolders.Values) | 158 | foreach (InventoryFolderImpl folder in SubFolders.Values) |
158 | { | 159 | { |
159 | found = folder.DeleteItem(itemID); | 160 | found = folder.DeleteItem(itemID); |
161 | |||
160 | if (found == true) | 162 | if (found == true) |
161 | { | 163 | { |
162 | break; | 164 | break; |
@@ -168,37 +170,35 @@ namespace OpenSim.Framework.Communications.Cache | |||
168 | } | 170 | } |
169 | 171 | ||
170 | /// <summary> | 172 | /// <summary> |
171 | /// Returns the folder requested if it exists as a descendent of this folder | 173 | /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth |
174 | /// first. | ||
172 | /// </summary> | 175 | /// </summary> |
173 | /// <returns>The requested folder if it exists, null if it does not.</returns> | 176 | /// <returns>The requested folder if it exists, null if it does not.</returns> |
174 | public InventoryFolderImpl FindFolder(LLUUID folderID) | 177 | public InventoryFolderImpl FindFolder(LLUUID folderID) |
175 | { | 178 | { |
176 | InventoryFolderImpl returnFolder = null; | 179 | if (folderID == ID) |
180 | { | ||
181 | return this; | ||
182 | } | ||
177 | 183 | ||
178 | lock (SubFolders) | 184 | lock (SubFolders) |
179 | { | 185 | { |
180 | if (SubFolders.ContainsKey(folderID)) | 186 | foreach (InventoryFolderImpl folder in SubFolders.Values) |
181 | { | ||
182 | returnFolder = SubFolders[folderID]; | ||
183 | } | ||
184 | else | ||
185 | { | 187 | { |
186 | foreach (InventoryFolderImpl folder in SubFolders.Values) | 188 | InventoryFolderImpl returnFolder = folder.FindFolder(folderID); |
189 | |||
190 | if (returnFolder != null) | ||
187 | { | 191 | { |
188 | returnFolder = folder.FindFolder(folderID); | 192 | return returnFolder; |
189 | if (returnFolder != null) | ||
190 | { | ||
191 | break; | ||
192 | } | ||
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | return returnFolder; | 197 | return null; |
198 | } | 198 | } |
199 | 199 | ||
200 | /// <summary> | 200 | /// <summary> |
201 | /// Return the list of items in this folder | 201 | /// Return the list of child items in this folder |
202 | /// </summary> | 202 | /// </summary> |
203 | public List<InventoryItemBase> RequestListOfItems() | 203 | public List<InventoryItemBase> RequestListOfItems() |
204 | { | 204 | { |