From 888151833b1b08a6a8686d75a0385232b7fa90e9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 9 Dec 2008 03:06:26 +0000 Subject: * Added primitive exception logging capabilities. * Disabled by default (see OpenSim.ini.example for how to enable) * Saves exceptions to a folder on disk (default "crashes") when enabled. * These reports can then be uploaded or posted to help debug an error. --- OpenSim/Framework/Util.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c1429df..23bdb94 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -560,6 +560,34 @@ namespace OpenSim.Framework return "."; } + // From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html + public static string GetUniqueFilename(string FileName) + { + int count = 0; + string Name; + + if (File.Exists(FileName)) + { + FileInfo f = new FileInfo(FileName); + + if (!string.IsNullOrEmpty(f.Extension)) + { + Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.')); + } + else + { + Name = f.FullName; + } + + while (File.Exists(FileName)) + { + count++; + FileName = Name + count + f.Extension; + } + } + return FileName; + } + // Nini (config) related Methods public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) { -- cgit v1.1