From 20653830fbd0c0104a62e9c1b71744284b77b754 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 2 Jan 2008 07:13:34 +0000 Subject: [PATCH] * Refactored out function to load specified AssetSet Xml This commit dedicated to 'Mohawk - Bad Girls (Need Love Too)' --- .../Filesystem/AssetLoaderFileSystem.cs | 21 ++++++++++++------- .../Communications/Cache/AssetServerBase.cs | 4 ++-- OpenSim/Framework/IAssetLoader.cs | 3 ++- OpenSim/Grid/AssetServer/Main.cs | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 46e6ae1077..d6ce0c5e39 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -79,18 +79,23 @@ namespace OpenSim.Framework.AssetLoader.Filesystem //info.loaded=true; } - public void ForEachXmlAsset(Action action) + public void ForEachDefaultXmlAsset(Action action) { - List assets = new List(); - string assetSetsPath = Path.Combine(Util.assetsDir(), "AssetSets.xml"); - - if (File.Exists(assetSetsPath)) + string assetSetFilename = Path.Combine(Util.assetsDir(), "AssetSets.xml"); + + ForEachDefaultXmlAsset(assetSetFilename, action); + } + + public void ForEachDefaultXmlAsset(string assetSetFilename, Action action) + { + List assets = new List(); + if (File.Exists(assetSetFilename)) { string assetSetPath = "ERROR"; try { - XmlConfigSource source = new XmlConfigSource(assetSetsPath); + XmlConfigSource source = new XmlConfigSource(assetSetFilename); for (int i = 0; i < source.Configs.Count; i++) { @@ -111,9 +116,9 @@ namespace OpenSim.Framework.AssetLoader.Filesystem "Asset set control file assets/AssetSets.xml does not exist! No assets loaded."); } - assets.ForEach(action); + assets.ForEach(action); } - + /// /// Use the asset set information at path to load assets /// diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 2153fbfa5f..318082b699 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -82,11 +82,11 @@ namespace OpenSim.Framework.Communications.Cache } } - public void LoadDefaultAssets() + public virtual void LoadDefaultAssets() { MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); - assetLoader.ForEachXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(StoreAsset); CommitAssets(); } diff --git a/OpenSim/Framework/IAssetLoader.cs b/OpenSim/Framework/IAssetLoader.cs index 6bcaa24af1..df0b81b7f7 100644 --- a/OpenSim/Framework/IAssetLoader.cs +++ b/OpenSim/Framework/IAssetLoader.cs @@ -32,6 +32,7 @@ namespace OpenSim.Framework { public interface IAssetLoader { - void ForEachXmlAsset(Action action); + void ForEachDefaultXmlAsset(Action action); + void ForEachDefaultXmlAsset(string assetSetFilename, Action action); } } diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index 01b2c02b46..ed77e3ece0 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -159,7 +159,7 @@ namespace OpenSim.Grid.AssetServer public void LoadDefaultAssets() { - assetLoader.ForEachXmlAsset(StoreAsset); + assetLoader.ForEachDefaultXmlAsset(StoreAsset); } protected void StoreAsset(AssetBase asset)