aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/Configger/Util.cs
diff options
context:
space:
mode:
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}