aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs')
-rw-r--r--OpenSim/Grid/NewAssetServer/Extensions/SimpleUtils.cs44
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 @@
1using System;
2using System.IO;
3using OpenMetaverse;
4
5namespace 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}