From 8d304725518424131fa42dce1515137e0bb1eada Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Mon, 16 Feb 2009 02:25:25 +0000 Subject: Rename NewAssetServer AssetInventoryServer and fully qualify with OpenSim.Grid.AssetInventoryServer. --- .../AssetInventoryServer/Extensions/SimpleUtils.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 OpenSim/Grid/AssetInventoryServer/Extensions/SimpleUtils.cs (limited to 'OpenSim/Grid/AssetInventoryServer/Extensions/SimpleUtils.cs') diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleUtils.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleUtils.cs new file mode 100644 index 0000000..fe6491e --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Extensions/SimpleUtils.cs @@ -0,0 +1,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; + } + } + } +} -- cgit v1.1