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 /OpenSim/Framework/Util.cs | |
parent | Complete the work on the Replaceable interface logic. From this commit onwards (diff) | |
download | opensim-SC-efc57bc3d79e9c3c0971a2715a407ad08e030f02.zip opensim-SC-efc57bc3d79e9c3c0971a2715a407ad08e030f02.tar.gz opensim-SC-efc57bc3d79e9c3c0971a2715a407ad08e030f02.tar.bz2 opensim-SC-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 |
1 files changed, 51 insertions, 0 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 | } |