aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs28
1 files changed, 28 insertions, 0 deletions
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
560 return "."; 560 return ".";
561 } 561 }
562 562
563 // From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html
564 public static string GetUniqueFilename(string FileName)
565 {
566 int count = 0;
567 string Name;
568
569 if (File.Exists(FileName))
570 {
571 FileInfo f = new FileInfo(FileName);
572
573 if (!string.IsNullOrEmpty(f.Extension))
574 {
575 Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.'));
576 }
577 else
578 {
579 Name = f.FullName;
580 }
581
582 while (File.Exists(FileName))
583 {
584 count++;
585 FileName = Name + count + f.Extension;
586 }
587 }
588 return FileName;
589 }
590
563 // Nini (config) related Methods 591 // Nini (config) related Methods
564 public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) 592 public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName)
565 { 593 {