diff options
author | Justin Clark-Casey (justincc) | 2010-02-08 21:39:46 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-02-08 21:39:46 +0000 |
commit | aba59088604bbc422af7f670226e1b5c91acab41 (patch) | |
tree | 9896e48143101a20eddf38921ad646702f48146b /OpenSim/Tools/Configger/Util.cs | |
parent | add some method doc to IDynamicTextureManager (diff) | |
parent | Adding the Careminster "Configger" tool to OpenSim. The tool will, when launched (diff) | |
download | opensim-SC_OLD-aba59088604bbc422af7f670226e1b5c91acab41.zip opensim-SC_OLD-aba59088604bbc422af7f670226e1b5c91acab41.tar.gz opensim-SC_OLD-aba59088604bbc422af7f670226e1b5c91acab41.tar.bz2 opensim-SC_OLD-aba59088604bbc422af7f670226e1b5c91acab41.tar.xz |
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Tools/Configger/Util.cs')
-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 | } | ||