From 5869598c4ca462bfda3b83b707c57433048f364c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 26 Jun 2009 00:00:20 +0000 Subject: [PATCH] Make delete-region delete the section from an ini file. Will delete the whole file if it has no sections left. --- OpenSim/Framework/RegionInfo.cs | 6 +++++ OpenSim/Region/Application/OpenSimBase.cs | 30 +++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index eb10facee1..504b3031e3 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -259,6 +259,8 @@ namespace OpenSim.Framework newFile.Save(filename); + RegionFile = filename; + return; } @@ -273,6 +275,8 @@ namespace OpenSim.Framework if (configName != String.Empty && saveFile) source.Save(filename); + RegionFile = filename; + return; } @@ -285,6 +289,8 @@ namespace OpenSim.Framework ReadNiniConfig(xmlsource, configName); + RegionFile = filename; + return; } catch (Exception) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 1ff53c9084..9e3dafb394 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -465,8 +465,34 @@ namespace OpenSim if (!String.IsNullOrEmpty(scene.RegionInfo.RegionFile)) { - File.Delete(scene.RegionInfo.RegionFile); - m_log.InfoFormat("[OPENSIM]: deleting region file \"{0}\"", scene.RegionInfo.RegionFile); + if (scene.RegionInfo.RegionFile.ToLower().EndsWith(".xml")) + { + File.Delete(scene.RegionInfo.RegionFile); + m_log.InfoFormat("[OPENSIM]: deleting region file \"{0}\"", scene.RegionInfo.RegionFile); + } + if (scene.RegionInfo.RegionFile.ToLower().EndsWith(".ini")) + { + try + { + IniConfigSource source = new IniConfigSource(scene.RegionInfo.RegionFile); + if (source.Configs[scene.RegionInfo.RegionName] != null) + { + source.Configs.Remove(scene.RegionInfo.RegionName); + + if (source.Configs.Count == 0) + { + File.Delete(scene.RegionInfo.RegionFile); + } + else + { + source.Save(scene.RegionInfo.RegionFile); + } + } + } + catch (Exception) + { + } + } } }