diff options
author | Melanie | 2009-08-06 02:29:12 +0100 |
---|---|---|
committer | Melanie | 2009-08-06 02:29:12 +0100 |
commit | efc57bc3d79e9c3c0971a2715a407ad08e030f02 (patch) | |
tree | ce617eb668ecf495668c2ceac5a6bc30d93f7671 | |
parent | Complete the work on the Replaceable interface logic. From this commit onwards (diff) | |
download | opensim-SC_OLD-efc57bc3d79e9c3c0971a2715a407ad08e030f02.zip opensim-SC_OLD-efc57bc3d79e9c3c0971a2715a407ad08e030f02.tar.gz opensim-SC_OLD-efc57bc3d79e9c3c0971a2715a407ad08e030f02.tar.bz2 opensim-SC_OLD-efc57bc3d79e9c3c0971a2715a407ad08e030f02.tar.xz |
Allow arbitrary wildcards in config includes. Things like
Include-Modules = "addin-modules/*/config/*.ini" will now work.
Adds Util.Glob, which will resolve a globbed path into a string list.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 51 | ||||
-rw-r--r-- | OpenSim/Region/Application/ConfigurationLoader.cs | 7 |
2 files changed, 55 insertions, 3 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0a9b67d..65d4f4d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1111,5 +1111,56 @@ namespace OpenSim.Framework | |||
1111 | return null; | 1111 | return null; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | public static string[] Glob(string path) | ||
1115 | { | ||
1116 | string vol=String.Empty; | ||
1117 | |||
1118 | if (Path.VolumeSeparatorChar != Path.DirectorySeparatorChar) | ||
1119 | { | ||
1120 | string[] vcomps = path.Split(new char[] {Path.VolumeSeparatorChar}, 2, StringSplitOptions.RemoveEmptyEntries); | ||
1121 | |||
1122 | if (vcomps.Length > 1) | ||
1123 | { | ||
1124 | path = vcomps[1]; | ||
1125 | vol = vcomps[0]; | ||
1126 | } | ||
1127 | } | ||
1128 | |||
1129 | string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries); | ||
1130 | |||
1131 | // Glob | ||
1132 | |||
1133 | path = vol; | ||
1134 | if (vol != String.Empty) | ||
1135 | path += new String(new char[] {Path.VolumeSeparatorChar, Path.DirectorySeparatorChar}); | ||
1136 | else | ||
1137 | path = new String(new char[] {Path.DirectorySeparatorChar}); | ||
1138 | |||
1139 | List<string> paths = new List<string>(); | ||
1140 | List<string> found = new List<string>(); | ||
1141 | paths.Add(path); | ||
1142 | |||
1143 | foreach (string c in comps) | ||
1144 | { | ||
1145 | List<string> addpaths = new List<string>(); | ||
1146 | foreach (string p in paths) | ||
1147 | { | ||
1148 | string[] dirs = Directory.GetDirectories(p, c); | ||
1149 | |||
1150 | if (dirs.Length != 0) | ||
1151 | { | ||
1152 | foreach (string dir in dirs) | ||
1153 | addpaths.Add(Path.Combine(path, dir)); | ||
1154 | } | ||
1155 | |||
1156 | string[] files = Directory.GetFiles(p, c); | ||
1157 | foreach (string f in files) | ||
1158 | found.Add(f); | ||
1159 | } | ||
1160 | paths = addpaths; | ||
1161 | } | ||
1162 | |||
1163 | return found.ToArray(); | ||
1164 | } | ||
1114 | } | 1165 | } |
1115 | } | 1166 | } |
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 1be36ca..7bb8864 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs | |||
@@ -188,10 +188,11 @@ namespace OpenSim | |||
188 | { | 188 | { |
189 | string path = Path.GetFullPath( | 189 | string path = Path.GetFullPath( |
190 | Path.Combine(Util.configDir(), file)); | 190 | Path.Combine(Util.configDir(), file)); |
191 | if (File.Exists(path)) | 191 | string[] paths = Util.Glob(path); |
192 | foreach (string p in paths) | ||
192 | { | 193 | { |
193 | if (!sources.Contains(path)) | 194 | if (!sources.Contains(p)) |
194 | sources.Add(path); | 195 | sources.Add(p); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | } | 198 | } |