Merged 3Di code that provides scene and avatar serialization, and plugin support for region move/split/merge. See ThirdParty/3Di/README.txt. Unless the new modules are used there should be no noticeable changes when running OpenSim.

This commit is contained in:
Johan Berntsson
2008-03-04 05:31:54 +00:00
parent cd6f4a57e7
commit 279e0061c5
44 changed files with 4503 additions and 126 deletions

View File

@@ -37,6 +37,8 @@ using System.Text;
using libsecondlife;
using Nini.Config;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace OpenSim.Framework
{
public class Util
@@ -509,7 +511,63 @@ namespace OpenSim.Framework
{
return "";
}
}
public static void SerializeToFile(string filename, Object obj)
{
IFormatter formatter = new BinaryFormatter();
Stream stream = null;
try
{
stream = new FileStream(
filename, FileMode.Create,
FileAccess.Write, FileShare.None);
formatter.Serialize(stream, obj);
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.StackTrace);
}
finally
{
if (stream != null)
{
stream.Close();
}
}
}
public static Object DeserializeFromFile(string filename)
{
IFormatter formatter = new BinaryFormatter();
Stream stream = null;
Object ret = null;
try
{
stream = new FileStream(
filename, FileMode.Open,
FileAccess.Read, FileShare.None);
ret = formatter.Deserialize(stream);
}
catch (Exception e)
{
System.Console.WriteLine(e.Message);
System.Console.WriteLine(e.StackTrace);
}
finally
{
if (stream != null)
{
stream.Close();
}
}
return ret;
}
}
}