diff options
author | Mike Mazur | 2009-02-16 02:24:57 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-16 02:24:57 +0000 |
commit | 0e09b4a08beddb3b0239a3f088ab9a230b8f3979 (patch) | |
tree | 481d1cb9a60062dea6e646e0e6c5d9d87ce40b6e /OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs | |
parent | Thank you, cmickeyb, for a patch to ass two string functions (diff) | |
download | opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.zip opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.gz opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.bz2 opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.xz |
Adding
- NewAssetServer code
- NewAssetServer addin manifest
- example AssetServer.ini file
Diffstat (limited to 'OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs')
-rw-r--r-- | OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs b/OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs new file mode 100644 index 0000000..6642f90 --- /dev/null +++ b/OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs | |||
@@ -0,0 +1,44 @@ | |||
1 | using System; | ||
2 | using System.IO; | ||
3 | using OpenMetaverse; | ||
4 | |||
5 | namespace AssetServer.Extensions | ||
6 | { | ||
7 | public static class SimpleUtils | ||
8 | { | ||
9 | public static string ParseNameFromFilename(string filename) | ||
10 | { | ||
11 | filename = Path.GetFileName(filename); | ||
12 | |||
13 | int dot = filename.LastIndexOf('.'); | ||
14 | int firstDash = filename.IndexOf('-'); | ||
15 | |||
16 | if (dot - 37 > 0 && firstDash > 0) | ||
17 | return filename.Substring(0, firstDash); | ||
18 | else | ||
19 | return String.Empty; | ||
20 | } | ||
21 | |||
22 | public static UUID ParseUUIDFromFilename(string filename) | ||
23 | { | ||
24 | int dot = filename.LastIndexOf('.'); | ||
25 | |||
26 | if (dot > 35) | ||
27 | { | ||
28 | // Grab the last 36 characters of the filename | ||
29 | string uuidString = filename.Substring(dot - 36, 36); | ||
30 | UUID uuid; | ||
31 | UUID.TryParse(uuidString, out uuid); | ||
32 | return uuid; | ||
33 | } | ||
34 | else | ||
35 | { | ||
36 | UUID uuid; | ||
37 | if (UUID.TryParse(Path.GetFileName(filename), out uuid)) | ||
38 | return uuid; | ||
39 | else | ||
40 | return UUID.Zero; | ||
41 | } | ||
42 | } | ||
43 | } | ||
44 | } | ||