diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Application/OpenSimMainConsole.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | 66 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs (renamed from OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs) | 10 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs | 108 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs (renamed from OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs) | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 6 |
7 files changed, 198 insertions, 14 deletions
diff --git a/OpenSim/Region/Application/OpenSimMainConsole.cs b/OpenSim/Region/Application/OpenSimMainConsole.cs index e4590f2..7b1b477 100644 --- a/OpenSim/Region/Application/OpenSimMainConsole.cs +++ b/OpenSim/Region/Application/OpenSimMainConsole.cs | |||
@@ -360,6 +360,19 @@ namespace OpenSim | |||
360 | } | 360 | } |
361 | break; | 361 | break; |
362 | 362 | ||
363 | case "load-oar": | ||
364 | m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); | ||
365 | |||
366 | if (cmdparams.Length > 0) | ||
367 | { | ||
368 | m_sceneManager.LoadArchiveToCurrentScene(cmdparams[0]); | ||
369 | } | ||
370 | else | ||
371 | { | ||
372 | m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); | ||
373 | } | ||
374 | break; | ||
375 | |||
363 | case "save-oar": | 376 | case "save-oar": |
364 | m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); | 377 | m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!"); |
365 | 378 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs new file mode 100644 index 0000000..0a3c4c5 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenSim.Region.Environment.Scenes; | ||
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | |||
32 | namespace OpenSim.Region.Environment.Modules.World.Archiver | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Handles an individual archive read request | ||
36 | /// </summary> | ||
37 | public class ArchiveReadRequest | ||
38 | { | ||
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
41 | private Scene m_scene; | ||
42 | private string m_loadPath; | ||
43 | |||
44 | public ArchiveReadRequest(Scene scene, string loadPath) | ||
45 | { | ||
46 | m_scene = scene; | ||
47 | m_loadPath = loadPath; | ||
48 | |||
49 | DearchiveRegion(); | ||
50 | } | ||
51 | |||
52 | protected void DearchiveRegion() | ||
53 | { | ||
54 | TarArchiveReader archive = new TarArchiveReader(m_loadPath); | ||
55 | |||
56 | // Just test for now by reading first file | ||
57 | string filePath = "ERROR"; | ||
58 | |||
59 | byte[] data = archive.Read(out filePath); | ||
60 | |||
61 | m_log.DebugFormat("Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); | ||
62 | |||
63 | archive.Close(); | ||
64 | } | ||
65 | } | ||
66 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs index 364b31f..b952200 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -44,9 +44,9 @@ namespace OpenSim.Region.Environment | |||
44 | public delegate void AssetsRequestCallback(IDictionary<LLUUID, AssetBase> assets); | 44 | public delegate void AssetsRequestCallback(IDictionary<LLUUID, AssetBase> assets); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Handles an individual archive request | 47 | /// Handles an individual archive write request |
48 | /// </summary> | 48 | /// </summary> |
49 | public class ArchiveRequest | 49 | public class ArchiveWriteRequest |
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment | |||
55 | 55 | ||
56 | private string m_serializedEntities; | 56 | private string m_serializedEntities; |
57 | 57 | ||
58 | public ArchiveRequest(Scene scene, string savePath) | 58 | public ArchiveWriteRequest(Scene scene, string savePath) |
59 | { | 59 | { |
60 | m_scene = scene; | 60 | m_scene = scene; |
61 | m_savePath = savePath; | 61 | m_savePath = savePath; |
@@ -65,8 +65,6 @@ namespace OpenSim.Region.Environment | |||
65 | 65 | ||
66 | protected void ArchiveRegion() | 66 | protected void ArchiveRegion() |
67 | { | 67 | { |
68 | m_log.Warn("[ARCHIVER]: Archive region not yet implemented"); | ||
69 | |||
70 | Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>(); | 68 | Dictionary<LLUUID, int> textureUuids = new Dictionary<LLUUID, int>(); |
71 | 69 | ||
72 | List<EntityBase> entities = m_scene.GetEntities(); | 70 | List<EntityBase> entities = m_scene.GetEntities(); |
@@ -103,7 +101,7 @@ namespace OpenSim.Region.Environment | |||
103 | 101 | ||
104 | // XXX: Shouldn't hijack the asset async callback thread like this - this is only temporary | 102 | // XXX: Shouldn't hijack the asset async callback thread like this - this is only temporary |
105 | 103 | ||
106 | TarArchive archive = new TarArchive(); | 104 | TarArchiveWriter archive = new TarArchiveWriter(); |
107 | 105 | ||
108 | archive.AddFile("prims.xml", m_serializedEntities); | 106 | archive.AddFile("prims.xml", m_serializedEntities); |
109 | 107 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs index cff9235..0e3123e 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs | |||
@@ -72,12 +72,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
72 | 72 | ||
73 | public void ArchiveRegion(string savePath) | 73 | public void ArchiveRegion(string savePath) |
74 | { | 74 | { |
75 | new ArchiveRequest(m_scene, savePath); | 75 | new ArchiveWriteRequest(m_scene, savePath); |
76 | } | 76 | } |
77 | 77 | ||
78 | public void DearchiveRegion(string loadPath) | 78 | public void DearchiveRegion(string loadPath) |
79 | { | 79 | { |
80 | m_log.Warn("[ARCHIVER]: Dearchive region not yet implemented"); | 80 | new ArchiveReadRequest(m_scene, loadPath); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } \ No newline at end of file | 83 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs new file mode 100644 index 0000000..e785c6c --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | //using System.Reflection; | ||
31 | //using log4net; | ||
32 | |||
33 | namespace OpenSim.Region.Environment.Modules.World.Archiver | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Temporary code to do the bare minimum required to read a tar archive for our purposes | ||
37 | /// </summary> | ||
38 | public class TarArchiveReader | ||
39 | { | ||
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Binary reader for the underlying stream | ||
46 | /// </summary> | ||
47 | protected BinaryReader m_br; | ||
48 | |||
49 | public TarArchiveReader(string archivePath) | ||
50 | { | ||
51 | m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open)); | ||
52 | } | ||
53 | |||
54 | public byte[] Read(out string filePath) | ||
55 | { | ||
56 | TarHeader header = ReadHeader(); | ||
57 | filePath = header.FilePath; | ||
58 | return m_br.ReadBytes(header.FileSize); | ||
59 | } | ||
60 | |||
61 | /// <summary> | ||
62 | /// Read the next 512 byte chunk of data as a tar header. | ||
63 | /// </summary> | ||
64 | /// <returns>A tar header struct</returns> | ||
65 | protected TarHeader ReadHeader() | ||
66 | { | ||
67 | TarHeader tarHeader = new TarHeader(); | ||
68 | |||
69 | byte[] header = m_br.ReadBytes(512); | ||
70 | |||
71 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | ||
72 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); | ||
73 | |||
74 | return tarHeader; | ||
75 | } | ||
76 | |||
77 | public void Close() | ||
78 | { | ||
79 | m_br.Close(); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Convert octal bytes to a decimal representation | ||
84 | /// </summary> | ||
85 | /// <param name="bytes"></param> | ||
86 | /// <returns></returns> | ||
87 | public static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count) | ||
88 | { | ||
89 | string oString = m_asciiEncoding.GetString(bytes, startIndex, count); | ||
90 | |||
91 | int d = 0; | ||
92 | |||
93 | foreach (char c in oString) | ||
94 | { | ||
95 | d <<= 3; | ||
96 | d |= c - '0'; | ||
97 | } | ||
98 | |||
99 | return d; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | public struct TarHeader | ||
104 | { | ||
105 | public string FilePath; | ||
106 | public int FileSize; | ||
107 | } | ||
108 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs index c7492fe..e951755 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchive.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs | |||
@@ -25,7 +25,6 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | |||
29 | using System; | 28 | using System; |
30 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
31 | using System.IO; | 30 | using System.IO; |
@@ -38,7 +37,7 @@ namespace OpenSim.Region.Environment | |||
38 | /// <summary> | 37 | /// <summary> |
39 | /// Temporary code to produce a tar archive in tar v7 format | 38 | /// Temporary code to produce a tar archive in tar v7 format |
40 | /// </summary> | 39 | /// </summary> |
41 | public class TarArchive | 40 | public class TarArchiveWriter |
42 | { | 41 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 43 | ||
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 66174bf..63146bd 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs | |||
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
192 | public void LoadCurrentSceneFromXml2(string filename) | 192 | public void LoadCurrentSceneFromXml2(string filename) |
193 | { | 193 | { |
194 | CurrentOrFirstScene.LoadPrimsFromXml2(filename); | 194 | CurrentOrFirstScene.LoadPrimsFromXml2(filename); |
195 | } | 195 | } |
196 | 196 | ||
197 | /// <summary> | 197 | /// <summary> |
198 | /// Save the current scene to an OpenSimulator archive. This archive will eventually include the prim's assets | 198 | /// Save the current scene to an OpenSimulator archive. This archive will eventually include the prim's assets |
@@ -209,9 +209,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
209 | /// their assets to the asset service. | 209 | /// their assets to the asset service. |
210 | /// </summary> | 210 | /// </summary> |
211 | /// <param name="filename"></param> | 211 | /// <param name="filename"></param> |
212 | public void LoadCurrentSceneFromArchive(string filename) | 212 | public void LoadArchiveToCurrentScene(string filename) |
213 | { | 213 | { |
214 | CurrentOrFirstScene.SavePrimsToArchive(filename); | 214 | CurrentOrFirstScene.LoadPrimsFromArchive(filename); |
215 | } | 215 | } |
216 | 216 | ||
217 | [Obsolete("TODO: Remove this warning by 0.7")] | 217 | [Obsolete("TODO: Remove this warning by 0.7")] |