blob: fe6491e400bf8fca86341b070f6cea7512b29785 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
using System;
using System.IO;
using OpenMetaverse;
namespace OpenSim.Grid.AssetInventoryServer.Extensions
{
public static class SimpleUtils
{
public static string ParseNameFromFilename(string filename)
{
filename = Path.GetFileName(filename);
int dot = filename.LastIndexOf('.');
int firstDash = filename.IndexOf('-');
if (dot - 37 > 0 && firstDash > 0)
return filename.Substring(0, firstDash);
else
return String.Empty;
}
public static UUID ParseUUIDFromFilename(string filename)
{
int dot = filename.LastIndexOf('.');
if (dot > 35)
{
// Grab the last 36 characters of the filename
string uuidString = filename.Substring(dot - 36, 36);
UUID uuid;
UUID.TryParse(uuidString, out uuid);
return uuid;
}
else
{
UUID uuid;
if (UUID.TryParse(Path.GetFileName(filename), out uuid))
return uuid;
else
return UUID.Zero;
}
}
}
}
|