aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World
diff options
context:
space:
mode:
authorDr Scofield2008-10-30 15:31:44 +0000
committerDr Scofield2008-10-30 15:31:44 +0000
commitb222d11b124fb89965837592c4f4df27e8785165 (patch)
tree5ccbc95353b4b06d4e24c8cc2a8959c5b6052cb4 /OpenSim/Region/Environment/Modules/World
parentFrom: Alan Webb (alan_webb@us.ibm.com) (diff)
downloadopensim-SC_OLD-b222d11b124fb89965837592c4f4df27e8785165.zip
opensim-SC_OLD-b222d11b124fb89965837592c4f4df27e8785165.tar.gz
opensim-SC_OLD-b222d11b124fb89965837592c4f4df27e8785165.tar.bz2
opensim-SC_OLD-b222d11b124fb89965837592c4f4df27e8785165.tar.xz
From: Alan Webb (alan_webb@us.ibm.com)
XIRCBrigeModule is transient, will merge it with IRCBridgeModule: extends/refactors IRCBridgeModule to support channel-per-region (if desired).
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs64
1 files changed, 63 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index b001b42..c3d017a 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -36,6 +36,7 @@ using System.IO;
36using System.IO.Compression; 36using System.IO.Compression;
37using System.Reflection; 37using System.Reflection;
38using System.Xml; 38using System.Xml;
39using System.Net;
39using OpenMetaverse; 40using OpenMetaverse;
40using log4net; 41using log4net;
41 42
@@ -70,7 +71,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
70 { 71 {
71 TarArchiveReader archive 72 TarArchiveReader archive
72 = new TarArchiveReader( 73 = new TarArchiveReader(
73 new GZipStream(new FileStream(m_loadPath, FileMode.Open), CompressionMode.Decompress)); 74 new GZipStream(GetStream(m_loadPath), CompressionMode.Decompress));
75
74 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); 76 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
75 77
76 List<string> serialisedSceneObjects = new List<string>(); 78 List<string> serialisedSceneObjects = new List<string>();
@@ -284,5 +286,65 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
284 286
285 return true; 287 return true;
286 } 288 }
289
290 /// <summary>
291 /// Resolve path to a working FileStream
292 /// </summary>
293
294 private Stream GetStream(string path)
295 {
296 try
297 {
298 if (File.Exists(path))
299 {
300 return new FileStream(path, FileMode.Open);
301 }
302 else
303 {
304 Uri uri = new Uri(path); // throw exception if not valid URI
305 if (uri.Scheme == "file")
306 {
307 return new FileStream(uri.AbsolutePath, FileMode.Open);
308 }
309 else
310 {
311 if (uri.Scheme != "http")
312 throw new Exception(String.Format("Unsupported URI scheme ({0})", path));
313
314 // OK, now we know we have an HTTP URI to work with
315
316 return URIFetch(uri);
317
318 }
319 }
320 }
321 catch (Exception e)
322 {
323 throw new Exception(String.Format("Unable to create file input stream for {0}: {1}", path, e));
324 }
325 }
326
327 private static Stream URIFetch(Uri uri)
328 {
329
330 HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
331
332 // request.Credentials = credentials;
333
334 request.ContentLength = 0;
335
336 WebResponse response = request.GetResponse();
337 Stream file = response.GetResponseStream();
338
339 if (response.ContentType != "application/x-oar")
340 throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString()));
341
342 if (response.ContentLength == 0)
343 throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
344
345 return new BufferedStream(file, (int) response.ContentLength);
346
347 }
348
287 } 349 }
288} 350}