aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-04 20:31:03 +0000
committerJustin Clarke Casey2009-03-04 20:31:03 +0000
commitb52ac542ade6af9ad404dcebf68be3bef769b0e1 (patch)
tree2a304eb111ed61080c04893f14f89858bedda2e2 /OpenSim/Region
parent* Whoops. Left MiniModule enabled to anyone. (potential security risk). Disab... (diff)
downloadopensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.zip
opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.gz
opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.bz2
opensim-SC_OLD-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.xz
* Add the abilty to load and save iar item nodes where folders have identical names
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs91
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs55
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs45
6 files changed, 161 insertions, 49 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 323d90c..93201e1 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -76,7 +76,7 @@ namespace OpenSim
76 /// <summary> 76 /// <summary>
77 /// The file used to load and save an opensim archive if no filename has been specified 77 /// The file used to load and save an opensim archive if no filename has been specified
78 /// </summary> 78 /// </summary>
79 protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene_oar.tar.gz"; 79 protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene.oar";
80 80
81 public ConfigSettings ConfigurationSettings 81 public ConfigSettings ConfigurationSettings
82 { 82 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs
index b274af2..e2bce16 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveConstants.cs
@@ -51,6 +51,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
51 public static readonly string ASSET_EXTENSION_SEPARATOR = "_"; 51 public static readonly string ASSET_EXTENSION_SEPARATOR = "_";
52 52
53 /// <summary> 53 /// <summary>
54 /// Used to separate components in an inventory node name
55 /// </summary>
56 public static readonly string INVENTORY_NODE_NAME_COMPONENT_SEPARATOR = "__";
57
58 /// <summary>
54 /// Extensions used for asset types in the archive 59 /// Extensions used for asset types in the archive
55 /// </summary> 60 /// </summary>
56 public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); 61 public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>();
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index fc63957..4a681bc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
85 85
86 if (contents.Equals("")) return null; 86 if (contents.Equals("")) return null;
87 87
88 reader.ReadStartElement("InventoryObject"); 88 reader.ReadStartElement("InventoryItem");
89 reader.ReadStartElement("Name"); 89 reader.ReadStartElement("Name");
90 item.Name = reader.ReadString(); 90 item.Name = reader.ReadString();
91 reader.ReadEndElement(); 91 reader.ReadEndElement();
@@ -138,10 +138,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
138 reader.ReadStartElement("GroupOwned"); 138 reader.ReadStartElement("GroupOwned");
139 item.GroupOwned = Convert.ToBoolean(reader.ReadString()); 139 item.GroupOwned = Convert.ToBoolean(reader.ReadString());
140 reader.ReadEndElement(); 140 reader.ReadEndElement();
141 //reader.ReadStartElement("ParentFolderID");
142 //item.Folder = UUID.Parse(reader.ReadString());
143 //reader.ReadEndElement();
144 //reader.ReadEndElement();
145 141
146 return item; 142 return item;
147 } 143 }
@@ -187,13 +183,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
187 183
188 if (null == rootDestinationFolder) 184 if (null == rootDestinationFolder)
189 { 185 {
190 // TODO: Later on, automatically create this folder if it does not exist 186 // Possibly provide an option later on to automatically create this folder if it does not exist
191 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); 187 m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
192 188
193 return nodesLoaded; 189 return nodesLoaded;
194 } 190 }
195 191
196 archive = new TarArchiveReader(m_loadStream); 192 archive = new TarArchiveReader(m_loadStream);
193
194 // In order to load identically named folders, we need to keep track of the folders that we have already
195 // created
196 Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
197 197
198 byte[] data; 198 byte[] data;
199 TarArchiveReader.TarEntryType entryType; 199 TarArchiveReader.TarEntryType entryType;
@@ -222,12 +222,72 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
222 item.Creator = m_userInfo.UserProfile.ID; 222 item.Creator = m_userInfo.UserProfile.ID;
223 item.Owner = m_userInfo.UserProfile.ID; 223 item.Owner = m_userInfo.UserProfile.ID;
224 224
225 filePath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length); 225 string fsPath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length);
226 filePath = filePath.Remove(filePath.LastIndexOf("/")); 226 fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
227 string originalFsPath = fsPath;
228
229 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
227 230
228 m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to file path {0}", filePath); 231 InventoryFolderImpl foundFolder = null;
232 while (null == foundFolder && fsPath.Length > 0)
233 {
234 if (foldersCreated.ContainsKey(fsPath))
235 {
236 m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath);
237 foundFolder = foldersCreated[fsPath];
238 }
239 else
240 {
241 // Don't include the last slash
242 int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);
243
244 if (penultimateSlashIndex >= 0)
245 {
246 fsPath = fsPath.Remove(penultimateSlashIndex + 1);
247 }
248 else
249 {
250 m_log.DebugFormat(
251 "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}",
252 originalFsPath);
253 fsPath = string.Empty;
254 foundFolder = rootDestinationFolder;
255 }
256 }
257 }
229 258
230 string[] rawFolders = filePath.Split(new char[] { '/' }); 259 string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
260 string[] rawDirsToCreate
261 = fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
262 int i = 0;
263
264 while (i < rawDirsToCreate.Length)
265 {
266 m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
267
268 int identicalNameIdentifierIndex
269 = rawDirsToCreate[i].LastIndexOf(
270 InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
271 string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
272
273 UUID newFolderId = UUID.Random();
274 m_userInfo.CreateFolder(
275 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
276 foundFolder = foundFolder.GetChildFolder(newFolderId);
277
278 // Record that we have now created this folder
279 fsPath += rawDirsToCreate[i] + "/";
280 m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
281 foldersCreated[fsPath] = foundFolder;
282
283 if (0 == i)
284 nodesLoaded.Add(foundFolder);
285
286 i++;
287 }
288
289 /*
290 string[] rawFolders = filePath.Split(new char[] { '/' });
231 291
232 // Find the folders that do exist along the path given 292 // Find the folders that do exist along the path given
233 int i = 0; 293 int i = 0;
@@ -257,16 +317,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
257 m_userInfo.CreateFolder( 317 m_userInfo.CreateFolder(
258 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); 318 rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
259 foundFolder = foundFolder.GetChildFolder(newFolderId); 319 foundFolder = foundFolder.GetChildFolder(newFolderId);
260 } 320 }
321 */
261 322
262 // Reset folder ID to the one in which we want to load it 323 // Reset folder ID to the one in which we want to load it
263 item.Folder = foundFolder.ID; 324 item.Folder = foundFolder.ID;
264
265 //item.Folder = rootDestinationFolder.ID;
266 325
267 m_userInfo.AddItem(item); 326 m_userInfo.AddItem(item);
268 successfulItemRestores++; 327 successfulItemRestores++;
269 nodesLoaded.Add(item); 328
329 // If we're loading an item directly into the given destination folder then we need to record
330 // it separately from any loaded root folders
331 if (rootDestinationFolder == foundFolder)
332 nodesLoaded.Add(item);
270 } 333 }
271 } 334 }
272 } 335 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 2b071f0..357ed40 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -106,14 +106,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
106 m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 106 m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
107 } 107 }
108 108
109 protected void saveInvItem(InventoryItemBase inventoryItem, string path) 109 protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
110 { 110 {
111 string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); 111 string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID);
112 StringWriter sw = new StringWriter(); 112 StringWriter sw = new StringWriter();
113 XmlTextWriter writer = new XmlTextWriter(sw); 113 XmlTextWriter writer = new XmlTextWriter(sw);
114 writer.Formatting = Formatting.Indented; 114 writer.Formatting = Formatting.Indented;
115 115
116 writer.WriteStartElement("InventoryObject"); 116 writer.WriteStartElement("InventoryItem");
117
117 writer.WriteStartElement("Name"); 118 writer.WriteStartElement("Name");
118 writer.WriteString(inventoryItem.Name); 119 writer.WriteString(inventoryItem.Name);
119 writer.WriteEndElement(); 120 writer.WriteEndElement();
@@ -168,9 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
168 writer.WriteStartElement("GroupOwned"); 169 writer.WriteStartElement("GroupOwned");
169 writer.WriteString(inventoryItem.GroupOwned.ToString()); 170 writer.WriteString(inventoryItem.GroupOwned.ToString());
170 writer.WriteEndElement(); 171 writer.WriteEndElement();
171 writer.WriteStartElement("ParentFolderID"); 172
172 writer.WriteString(inventoryItem.Folder.ToString());
173 writer.WriteEndElement();
174 writer.WriteEndElement(); 173 writer.WriteEndElement();
175 174
176 archive.AddFile(filename, sw.ToString()); 175 archive.AddFile(filename, sw.ToString());
@@ -178,20 +177,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
178 m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, assetUuids); 177 m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, assetUuids);
179 } 178 }
180 179
181 protected void saveInvDir(InventoryFolderImpl inventoryFolder, string path) 180 protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path)
182 { 181 {
183 List<InventoryFolderImpl> inventories = inventoryFolder.RequestListOfFolderImpls(); 182 path +=
184 List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); 183 string.Format(
185 string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER; 184 "{0}{1}{2}/",
186 archive.AddDir(newPath); 185 inventoryFolder.Name,
186 InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
187 inventoryFolder.ID);
188 archive.AddDir(path);
189
190 List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls();
191 List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
192
193 /*
194 Dictionary identicalFolderNames = new Dictionary<string, int>();
187 195
188 foreach (InventoryFolderImpl folder in inventories) 196 foreach (InventoryFolderImpl folder in inventories)
189 { 197 {
190 saveInvDir(folder, newPath); 198
199 if (!identicalFolderNames.ContainsKey(folder.Name))
200 identicalFolderNames[folder.Name] = 0;
201 else
202 identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++;
203
204 int folderNameNumber = identicalFolderName[folder.Name];
205
206 SaveInvDir(
207 folder,
208 string.Format(
209 "{0}{1}{2}/",
210 path, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber));
211 }
212 */
213
214 foreach (InventoryFolderImpl childFolder in childFolders)
215 {
216 SaveInvDir(childFolder, path);
191 } 217 }
218
192 foreach (InventoryItemBase item in items) 219 foreach (InventoryItemBase item in items)
193 { 220 {
194 saveInvItem(item, newPath); 221 SaveInvItem(item, path);
195 } 222 }
196 } 223 }
197 224
@@ -270,7 +297,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
270 inventoryItem.Name, inventoryItem.ID, m_invPath); 297 inventoryItem.Name, inventoryItem.ID, m_invPath);
271 298
272 //get and export item info 299 //get and export item info
273 saveInvItem(inventoryItem, m_invPath); 300 SaveInvItem(inventoryItem, m_invPath);
274 } 301 }
275 } 302 }
276 else 303 else
@@ -280,7 +307,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
280 inventoryFolder.Name, inventoryFolder.ID, m_invPath); 307 inventoryFolder.Name, inventoryFolder.ID, m_invPath);
281 308
282 //recurse through all dirs getting dirs and files 309 //recurse through all dirs getting dirs and files
283 saveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH); 310 SaveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH);
284 } 311 }
285 312
286 new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute(); 313 new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute();
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index cb613f7..5cc0340 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -124,15 +124,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
124 MemoryStream archiveReadStream = new MemoryStream(archive); 124 MemoryStream archiveReadStream = new MemoryStream(archive);
125 TarArchiveReader tar = new TarArchiveReader(archiveReadStream); 125 TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
126 126
127 InventoryFolderImpl objectsFolder = userInfo.RootFolder.FindFolderByPath("Objects");
128
127 //bool gotControlFile = false; 129 //bool gotControlFile = false;
128 bool gotObject1File = false; 130 bool gotObject1File = false;
129 //bool gotObject2File = false; 131 //bool gotObject2File = false;
130 string expectedObject1FilePath = string.Format( 132 string expectedObject1FilePath = string.Format(
131 "{0}{1}{2}_{3}.xml", 133 "{0}{1}/{2}_{3}.xml",
132 InventoryArchiveConstants.INVENTORY_PATH, 134 InventoryArchiveConstants.INVENTORY_PATH,
133 "Objects/", 135 string.Format(
136 "Objects{0}{1}", InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objectsFolder.ID),
134 item1.Name, 137 item1.Name,
135 item1Id); 138 item1Id);
139
136/* 140/*
137 string expectedObject2FileName = string.Format( 141 string expectedObject2FileName = string.Format(
138 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml", 142 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
@@ -146,6 +150,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
146 150
147 while (tar.ReadEntry(out filePath, out tarEntryType) != null) 151 while (tar.ReadEntry(out filePath, out tarEntryType) != null)
148 { 152 {
153 Console.WriteLine("Got {0}", filePath);
154
149 /* 155 /*
150 if (ArchiveConstants.CONTROL_FILE_PATH == filePath) 156 if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
151 { 157 {
@@ -153,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
153 } 159 }
154 */ 160 */
155 if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) 161 if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
156 { 162 {
157 //string fileName = filePath.Remove(0, "Objects/".Length); 163 //string fileName = filePath.Remove(0, "Objects/".Length);
158 164
159 //if (fileName.StartsWith(part1.Name)) 165 //if (fileName.StartsWith(part1.Name))
diff --git a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs
index afe5938..19d2629 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs
@@ -89,22 +89,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
89 return null; 89 return null;
90 90
91 entryType = header.EntryType; 91 entryType = header.EntryType;
92 filePath = header.FilePath; 92 filePath = header.FilePath;
93 byte[] data = m_br.ReadBytes(header.FileSize); 93 return ReadData(header.FileSize);
94
95 //m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize);
96
97 // Read the rest of the empty padding in the 512 byte block
98 if (header.FileSize % 512 != 0)
99 {
100 int paddingLeft = 512 - (header.FileSize % 512);
101
102 //m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft);
103
104 m_br.ReadBytes(paddingLeft);
105 }
106
107 return data;
108 } 94 }
109 95
110 /// <summary> 96 /// <summary>
@@ -126,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
126 if (header[156] == (byte)'L') 112 if (header[156] == (byte)'L')
127 { 113 {
128 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); 114 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
129 tarHeader.FilePath = m_asciiEncoding.GetString(m_br.ReadBytes(longNameLength)); 115 tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength));
130 m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); 116 m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath);
131 header = m_br.ReadBytes(512); 117 header = m_br.ReadBytes(512);
132 } 118 }
@@ -134,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
134 { 120 {
135 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); 121 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
136 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 122 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
123 m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
137 } 124 }
138 125
139 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); 126 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
@@ -171,6 +158,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
171 158
172 return tarHeader; 159 return tarHeader;
173 } 160 }
161
162 /// <summary>
163 /// Read data following a header
164 /// </summary>
165 /// <param name="fileSize"></param>
166 /// <returns></returns>
167 protected byte[] ReadData(int fileSize)
168 {
169 byte[] data = m_br.ReadBytes(fileSize);
170
171 m_log.DebugFormat("[TAR ARCHIVE READER]: fileSize {0}", fileSize);
172
173 // Read the rest of the empty padding in the 512 byte block
174 if (fileSize % 512 != 0)
175 {
176 int paddingLeft = 512 - (fileSize % 512);
177
178 m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft);
179
180 m_br.ReadBytes(paddingLeft);
181 }
182
183 return data;
184 }
174 185
175 public void Close() 186 public void Close()
176 { 187 {