aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/Configger/Util.cs
diff options
context:
space:
mode:
authorMelanie2010-02-08 15:21:35 +0000
committerMelanie2010-02-08 15:21:35 +0000
commit70a0d7aa4677c240ad12527adde6725df946e572 (patch)
treef5fb26c626a2b13c057fd4a0d902346501e176c0 /OpenSim/Tools/Configger/Util.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim into mysql-p... (diff)
downloadopensim-SC-70a0d7aa4677c240ad12527adde6725df946e572.zip
opensim-SC-70a0d7aa4677c240ad12527adde6725df946e572.tar.gz
opensim-SC-70a0d7aa4677c240ad12527adde6725df946e572.tar.bz2
opensim-SC-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 'OpenSim/Tools/Configger/Util.cs')
-rw-r--r--OpenSim/Tools/Configger/Util.cs79
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 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Globalization;
5using System.IO;
6using System.IO.Compression;
7using System.Net;
8using System.Net.Sockets;
9using System.Reflection;
10using System.Text;
11using System.Text.RegularExpressions;
12using System.Threading;
13using log4net;
14using Nini.Config;
15
16namespace 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}