diff options
author | Dr Scofield | 2008-10-30 15:31:44 +0000 |
---|---|---|
committer | Dr Scofield | 2008-10-30 15:31:44 +0000 |
commit | b222d11b124fb89965837592c4f4df27e8785165 (patch) | |
tree | 5ccbc95353b4b06d4e24c8cc2a8959c5b6052cb4 /OpenSim/Region/Environment/Modules/World | |
parent | From: Alan Webb (alan_webb@us.ibm.com) (diff) | |
download | opensim-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.cs | 64 |
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; | |||
36 | using System.IO.Compression; | 36 | using System.IO.Compression; |
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using System.Xml; | 38 | using System.Xml; |
39 | using System.Net; | ||
39 | using OpenMetaverse; | 40 | using OpenMetaverse; |
40 | using log4net; | 41 | using 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 | } |