Consistency patch: use Path.Combine() instead of + and eliminate the need

for a trailing slash on exports/
viewer-2-initial-appearance
Melanie 2010-09-26 20:03:00 +01:00
parent 14db53b723
commit dc49057c8a
3 changed files with 9 additions and 8 deletions

View File

@ -41,7 +41,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
public string WriteToFile(Scene scene, string dir) public string WriteToFile(Scene scene, string dir)
{ {
string targetFileName = dir + "objects.xml"; string targetFileName = Path.Combine(dir, "objects.xml");
SaveSerialisedToFile(targetFileName, scene); SaveSerialisedToFile(targetFileName, scene);

View File

@ -28,6 +28,7 @@
using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.CoreModules.World.Terrain.FileLoaders; using OpenSim.Region.CoreModules.World.Terrain.FileLoaders;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using System.IO;
namespace OpenSim.Region.CoreModules.World.Serialiser namespace OpenSim.Region.CoreModules.World.Serialiser
{ {
@ -38,7 +39,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
public string WriteToFile(Scene scene, string dir) public string WriteToFile(Scene scene, string dir)
{ {
ITerrainLoader fileSystemExporter = new RAW32(); ITerrainLoader fileSystemExporter = new RAW32();
string targetFileName = dir + "heightmap.r32"; string targetFileName = Path.Combine(dir, "heightmap.r32");
lock (scene.Heightmap) lock (scene.Heightmap)
{ {
@ -50,4 +51,4 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
#endregion #endregion
} }
} }

View File

@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
private Commander m_commander = new Commander("export"); private Commander m_commander = new Commander("export");
private List<Scene> m_regions = new List<Scene>(); private List<Scene> m_regions = new List<Scene>();
private string m_savedir = "exports" + "/"; private string m_savedir = "exports";
private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
#region ISharedRegionModule Members #region ISharedRegionModule Members
@ -192,14 +192,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
} }
} }
TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); TextWriter regionInfoWriter = new StreamWriter(Path.Combine(saveDir, "README.TXT"));
regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
regionInfoWriter.WriteLine("Serialise Version: 0.1"); regionInfoWriter.WriteLine("Serialise Version: 0.1");
regionInfoWriter.Close(); regionInfoWriter.Close();
TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); TextWriter manifestWriter = new StreamWriter(Path.Combine(saveDir, "region.manifest"));
foreach (string line in results) foreach (string line in results)
{ {
manifestWriter.WriteLine(line); manifestWriter.WriteLine(line);
@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
if (region.RegionInfo.RegionName == (string) args[0]) if (region.RegionInfo.RegionName == (string) args[0])
{ {
// List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); // List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); SerialiseRegion(region, Path.Combine(m_savedir, region.RegionInfo.RegionID.ToString()));
} }
} }
} }
@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
foreach (Scene region in m_regions) foreach (Scene region in m_regions)
{ {
// List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); // List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/"); SerialiseRegion(region, Path.Combine(m_savedir, region.RegionInfo.RegionID.ToString()));
} }
} }