aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Archiver')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs48
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs20
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs68
3 files changed, 68 insertions, 68 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index 0c5edaa..6a3b519 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -41,10 +41,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
41 /// </summary> 41 /// </summary>
42 public class ArchiveReadRequest 42 public class ArchiveReadRequest
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); 46 protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
47 47
48 private Scene m_scene; 48 private Scene m_scene;
49 private string m_loadPath; 49 private string m_loadPath;
50 50
@@ -55,22 +55,22 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
55 55
56 DearchiveRegion(); 56 DearchiveRegion();
57 } 57 }
58 58
59 protected void DearchiveRegion() 59 protected void DearchiveRegion()
60 { 60 {
61 TarArchiveReader archive = new TarArchiveReader(m_loadPath); 61 TarArchiveReader archive = new TarArchiveReader(m_loadPath);
62 62
63 string serializedPrims = string.Empty; 63 string serializedPrims = string.Empty;
64 64
65 // Just test for now by reading first file 65 // Just test for now by reading first file
66 string filePath = "ERROR"; 66 string filePath = "ERROR";
67 67
68 byte[] data; 68 byte[] data;
69 while ((data = archive.ReadEntry(out filePath)) != null) 69 while ((data = archive.ReadEntry(out filePath)) != null)
70 { 70 {
71 m_log.DebugFormat( 71 m_log.DebugFormat(
72 "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); 72 "[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath);
73 73
74 if (filePath.Equals(ArchiveConstants.PRIMS_PATH)) 74 if (filePath.Equals(ArchiveConstants.PRIMS_PATH))
75 { 75 {
76 serializedPrims = m_asciiEncoding.GetString(data); 76 serializedPrims = m_asciiEncoding.GetString(data);
@@ -78,37 +78,37 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
78 else if (filePath.StartsWith(ArchiveConstants.TEXTURES_PATH)) 78 else if (filePath.StartsWith(ArchiveConstants.TEXTURES_PATH))
79 { 79 {
80 // Right now we're nastily obtaining the lluuid from the filename 80 // Right now we're nastily obtaining the lluuid from the filename
81 string rawId = filePath.Remove(0, ArchiveConstants.TEXTURES_PATH.Length); 81 string rawId = filePath.Remove(0, ArchiveConstants.TEXTURES_PATH.Length);
82 rawId = rawId.Remove(rawId.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); 82 rawId = rawId.Remove(rawId.Length - ArchiveConstants.TEXTURE_EXTENSION.Length);
83 83
84 m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", rawId); 84 m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", rawId);
85 85
86 // Not preserving asset name or description as of yet 86 // Not preserving asset name or description as of yet
87 AssetBase asset = new AssetBase(new LLUUID(rawId), "imported name"); 87 AssetBase asset = new AssetBase(new LLUUID(rawId), "imported name");
88 asset.Description = "imported description"; 88 asset.Description = "imported description";
89 89
90 asset.Type = (sbyte)AssetType.Texture; 90 asset.Type = (sbyte)AssetType.Texture;
91 asset.InvType = (sbyte)InventoryType.Texture; 91 asset.InvType = (sbyte)InventoryType.Texture;
92 92
93 asset.Data = data; 93 asset.Data = data;
94 94
95 m_scene.AssetCache.AddAsset(asset); 95 m_scene.AssetCache.AddAsset(asset);
96 } 96 }
97 } 97 }
98 98
99 m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); 99 m_log.DebugFormat("[ARCHIVER]: Reached end of archive");
100 100
101 archive.Close(); 101 archive.Close();
102 102
103 if (serializedPrims.Equals(string.Empty)) 103 if (serializedPrims.Equals(string.Empty))
104 { 104 {
105 m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH); 105 m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH);
106 return; 106 return;
107 } 107 }
108 108
109 // Reload serialized prims 109 // Reload serialized prims
110 m_log.InfoFormat("[ARCHIVER]: Loading prim data"); 110 m_log.InfoFormat("[ARCHIVER]: Loading prim data");
111 111
112 IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>(); 112 IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
113 serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims)); 113 serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims));
114 } 114 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
index 1cc8877..6c341c6 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs
@@ -80,16 +80,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
80 { 80 {
81 // XXX: Not a great way to iterate through face textures, but there's no 81 // XXX: Not a great way to iterate through face textures, but there's no
82 // other way to tell how many faces there actually are 82 // other way to tell how many faces there actually are
83 //int i = 0; 83 //int i = 0;
84 foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures) 84 foreach (LLObject.TextureEntryFace texture in part.Shape.Textures.FaceTextures)
85 { 85 {
86 if (texture != null) 86 if (texture != null)
87 { 87 {
88 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); 88 //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
89 textureUuids[texture.TextureID] = 1; 89 textureUuids[texture.TextureID] = 1;
90 } 90 }
91 } 91 }
92 92
93 foreach (TaskInventoryItem tit in part.TaskInventory.Values) 93 foreach (TaskInventoryItem tit in part.TaskInventory.Values)
94 { 94 {
95 if (tit.Type == (int)InventoryType.Texture) 95 if (tit.Type == (int)InventoryType.Texture)
@@ -123,7 +123,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
123 TarArchiveWriter archive = new TarArchiveWriter(); 123 TarArchiveWriter archive = new TarArchiveWriter();
124 124
125 archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities); 125 archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities);
126 126
127 // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar 127 // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
128 //archive.AddDir("assets"); 128 //archive.AddDir("assets");
129 129
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
132 if (assets[uuid] != null) 132 if (assets[uuid] != null)
133 { 133 {
134 archive.AddFile( 134 archive.AddFile(
135 ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, 135 ArchiveConstants.TEXTURES_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION,
136 assets[uuid].Data); 136 assets[uuid].Data);
137 } 137 }
138 else 138 else
@@ -142,7 +142,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
142 } 142 }
143 143
144 archive.WriteTar(m_savePath); 144 archive.WriteTar(m_savePath);
145 145
146 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); 146 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
147 } 147 }
148 148
@@ -232,11 +232,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
232 newThread.Start(); 232 newThread.Start();
233 } 233 }
234 } 234 }
235 235
236 /// <summary> 236 /// <summary>
237 /// Perform the callback on the original requester of the assets 237 /// Perform the callback on the original requester of the assets
238 /// </summary> 238 /// </summary>
239 protected void PerformAssetsRequestCallback() 239 protected void PerformAssetsRequestCallback()
240 { 240 {
241 m_assetsRequestCallback(m_assets); 241 m_assetsRequestCallback(m_assets);
242 } 242 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
index b199d5f..463e172 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
@@ -39,24 +39,24 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
39 public class TarArchiveReader 39 public class TarArchiveReader
40 { 40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44 44
45 /// <summary> 45 /// <summary>
46 /// Binary reader for the underlying stream 46 /// Binary reader for the underlying stream
47 /// </summary> 47 /// </summary>
48 protected BinaryReader m_br; 48 protected BinaryReader m_br;
49 49
50 /// <summary> 50 /// <summary>
51 /// Used to trim off null chars 51 /// Used to trim off null chars
52 /// </summary> 52 /// </summary>
53 protected char[] m_nullCharArray = new char[] { '\0' }; 53 protected char[] m_nullCharArray = new char[] { '\0' };
54 54
55 public TarArchiveReader(string archivePath) 55 public TarArchiveReader(string archivePath)
56 { 56 {
57 m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open)); 57 m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
58 } 58 }
59 59
60 /// <summary> 60 /// <summary>
61 /// Are we at the end of the archive? 61 /// Are we at the end of the archive?
62 /// </summary> 62 /// </summary>
@@ -64,13 +64,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
64 public bool AtEof() 64 public bool AtEof()
65 { 65 {
66 // If we've reached the end of the archive we'll be in null block territory, which means 66 // If we've reached the end of the archive we'll be in null block territory, which means
67 // the next byte will be 0 67 // the next byte will be 0
68 if (m_br.PeekChar() == 0) 68 if (m_br.PeekChar() == 0)
69 return true; 69 return true;
70 70
71 return false; 71 return false;
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// Read the next entry in the tar file. 75 /// Read the next entry in the tar file.
76 /// </summary> 76 /// </summary>
@@ -79,27 +79,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
79 public byte[] ReadEntry(out string filePath) 79 public byte[] ReadEntry(out string filePath)
80 { 80 {
81 filePath = String.Empty; 81 filePath = String.Empty;
82 82
83 if (AtEof()) 83 if (AtEof())
84 return null; 84 return null;
85 85
86 TarHeader header = ReadHeader(); 86 TarHeader header = ReadHeader();
87 87
88 filePath = header.FilePath; 88 filePath = header.FilePath;
89 byte[] data = m_br.ReadBytes(header.FileSize); 89 byte[] data = m_br.ReadBytes(header.FileSize);
90 90
91 m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize); 91 m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize);
92 92
93 // Read the rest of the empty padding in the 512 byte block 93 // Read the rest of the empty padding in the 512 byte block
94 if (header.FileSize % 512 != 0) 94 if (header.FileSize % 512 != 0)
95 { 95 {
96 int paddingLeft = 512 - (header.FileSize % 512); 96 int paddingLeft = 512 - (header.FileSize % 512);
97 97
98 m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft); 98 m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft);
99 99
100 m_br.ReadBytes(paddingLeft); 100 m_br.ReadBytes(paddingLeft);
101 } 101 }
102 102
103 return data; 103 return data;
104 } 104 }
105 105
@@ -109,44 +109,44 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
109 /// </summary> 109 /// </summary>
110 /// <returns>A tar header struct.</returns> 110 /// <returns>A tar header struct.</returns>
111 protected TarHeader ReadHeader() 111 protected TarHeader ReadHeader()
112 { 112 {
113 TarHeader tarHeader = new TarHeader(); 113 TarHeader tarHeader = new TarHeader();
114 114
115 byte[] header = m_br.ReadBytes(512); 115 byte[] header = m_br.ReadBytes(512);
116 116
117 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); 117 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
118 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 118 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
119 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); 119 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
120 120
121 return tarHeader; 121 return tarHeader;
122 } 122 }
123 123
124 public void Close() 124 public void Close()
125 { 125 {
126 m_br.Close(); 126 m_br.Close();
127 } 127 }
128 128
129 /// <summary> 129 /// <summary>
130 /// Convert octal bytes to a decimal representation 130 /// Convert octal bytes to a decimal representation
131 /// </summary> 131 /// </summary>
132 /// <param name="bytes"></param> 132 /// <param name="bytes"></param>
133 /// <returns></returns> 133 /// <returns></returns>
134 public static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count) 134 public static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count)
135 { 135 {
136 string oString = m_asciiEncoding.GetString(bytes, startIndex, count); 136 string oString = m_asciiEncoding.GetString(bytes, startIndex, count);
137 137
138 int d = 0; 138 int d = 0;
139 139
140 foreach (char c in oString) 140 foreach (char c in oString)
141 { 141 {
142 d <<= 3; 142 d <<= 3;
143 d |= c - '0'; 143 d |= c - '0';
144 } 144 }
145 145
146 return d; 146 return d;
147 } 147 }
148 } 148 }
149 149
150 public struct TarHeader 150 public struct TarHeader
151 { 151 {
152 public string FilePath; 152 public string FilePath;