diff options
author | Melanie | 2010-02-08 15:21:35 +0000 |
---|---|---|
committer | Melanie | 2010-02-08 15:21:35 +0000 |
commit | 70a0d7aa4677c240ad12527adde6725df946e572 (patch) | |
tree | f5fb26c626a2b13c057fd4a0d902346501e176c0 /OpenSim/Tools/Configger/Util.cs | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim into mysql-p... (diff) | |
download | opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.zip opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.gz opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.bz2 opensim-SC_OLD-70a0d7aa4677c240ad12527adde6725df946e572.tar.xz |
Adding the Careminster "Configger" tool to OpenSim. The tool will, when launched
in place of OpenSim, dump the config to stdout. Use -f xml, -f ini or -f mysql
to get a condensed ini file, an xml file suitable for webloading, or a set
of mysql insert statements.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tools/Configger/Util.cs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/OpenSim/Tools/Configger/Util.cs b/OpenSim/Tools/Configger/Util.cs new file mode 100644 index 0000000..6f8aa76 --- /dev/null +++ b/OpenSim/Tools/Configger/Util.cs | |||
@@ -0,0 +1,79 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Globalization; | ||
5 | using System.IO; | ||
6 | using System.IO.Compression; | ||
7 | using System.Net; | ||
8 | using System.Net.Sockets; | ||
9 | using System.Reflection; | ||
10 | using System.Text; | ||
11 | using System.Text.RegularExpressions; | ||
12 | using System.Threading; | ||
13 | using log4net; | ||
14 | using Nini.Config; | ||
15 | |||
16 | namespace Careminster | ||
17 | { | ||
18 | public static class Util | ||
19 | { | ||
20 | public static string[] Glob(string path) | ||
21 | { | ||
22 | string vol=String.Empty; | ||
23 | |||
24 | if (Path.VolumeSeparatorChar != Path.DirectorySeparatorChar) | ||
25 | { | ||
26 | string[] vcomps = path.Split(new char[] {Path.VolumeSeparatorChar}, 2, StringSplitOptions.RemoveEmptyEntries); | ||
27 | |||
28 | if (vcomps.Length > 1) | ||
29 | { | ||
30 | path = vcomps[1]; | ||
31 | vol = vcomps[0]; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | string[] comps = path.Split(new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}, StringSplitOptions.RemoveEmptyEntries); | ||
36 | |||
37 | // Glob | ||
38 | |||
39 | path = vol; | ||
40 | if (vol != String.Empty) | ||
41 | path += new String(new char[] {Path.VolumeSeparatorChar, Path.DirectorySeparatorChar}); | ||
42 | else | ||
43 | path = new String(new char[] {Path.DirectorySeparatorChar}); | ||
44 | |||
45 | List<string> paths = new List<string>(); | ||
46 | List<string> found = new List<string>(); | ||
47 | paths.Add(path); | ||
48 | |||
49 | int compIndex = -1; | ||
50 | foreach (string c in comps) | ||
51 | { | ||
52 | compIndex++; | ||
53 | |||
54 | List<string> addpaths = new List<string>(); | ||
55 | foreach (string p in paths) | ||
56 | { | ||
57 | string[] dirs = Directory.GetDirectories(p, c); | ||
58 | |||
59 | if (dirs.Length != 0) | ||
60 | { | ||
61 | foreach (string dir in dirs) | ||
62 | addpaths.Add(Path.Combine(path, dir)); | ||
63 | } | ||
64 | |||
65 | // Only add files if that is the last path component | ||
66 | if (compIndex == comps.Length - 1) | ||
67 | { | ||
68 | string[] files = Directory.GetFiles(p, c); | ||
69 | foreach (string f in files) | ||
70 | found.Add(f); | ||
71 | } | ||
72 | } | ||
73 | paths = addpaths; | ||
74 | } | ||
75 | |||
76 | return found.ToArray(); | ||
77 | } | ||
78 | } | ||
79 | } | ||