aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorJohan Berntsson2008-03-04 05:31:54 +0000
committerJohan Berntsson2008-03-04 05:31:54 +0000
commit279e0061c515ee0a03036bef68eea9738273d785 (patch)
tree4502228eb7b87a760e0b0e67aded9d1d870d0bed /OpenSim/Framework/Util.cs
parentAdded copyright heaaders. Minor cleanup. (diff)
downloadopensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.zip
opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.tar.gz
opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.tar.bz2
opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 35e795b..8ba6643 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -37,6 +37,8 @@ using System.Text;
37using libsecondlife; 37using libsecondlife;
38using Nini.Config; 38using Nini.Config;
39 39
40using System.Runtime.Serialization;
41using System.Runtime.Serialization.Formatters.Binary;
40namespace OpenSim.Framework 42namespace OpenSim.Framework
41{ 43{
42 public class Util 44 public class Util
@@ -509,7 +511,63 @@ namespace OpenSim.Framework
509 { 511 {
510 return ""; 512 return "";
511 } 513 }
514 }
515
516 public static void SerializeToFile(string filename, Object obj)
517 {
518 IFormatter formatter = new BinaryFormatter();
519 Stream stream = null;
520
521 try
522 {
523 stream = new FileStream(
524 filename, FileMode.Create,
525 FileAccess.Write, FileShare.None);
526
527 formatter.Serialize(stream, obj);
528 }
529 catch (Exception e)
530 {
531 System.Console.WriteLine(e.Message);
532 System.Console.WriteLine(e.StackTrace);
533 }
534 finally
535 {
536 if (stream != null)
537 {
538 stream.Close();
539 }
540 }
541 }
542
543 public static Object DeserializeFromFile(string filename)
544 {
545 IFormatter formatter = new BinaryFormatter();
546 Stream stream = null;
547 Object ret = null;
548
549 try
550 {
551 stream = new FileStream(
552 filename, FileMode.Open,
553 FileAccess.Read, FileShare.None);
554
555 ret = formatter.Deserialize(stream);
556 }
557 catch (Exception e)
558 {
559 System.Console.WriteLine(e.Message);
560 System.Console.WriteLine(e.StackTrace);
561 }
562 finally
563 {
564 if (stream != null)
565 {
566 stream.Close();
567 }
568 }
512 569
570 return ret;
513 } 571 }
514 } 572 }
515} 573}