diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index f97ae5f..bc653ce 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
78 | 78 | ||
79 | try | 79 | try |
80 | { | 80 | { |
81 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); | 81 | m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress); |
82 | } | 82 | } |
83 | catch (EntryPointNotFoundException e) | 83 | catch (EntryPointNotFoundException e) |
84 | { | 84 | { |
@@ -471,68 +471,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
471 | } | 471 | } |
472 | 472 | ||
473 | /// <summary> | 473 | /// <summary> |
474 | /// Resolve path to a working FileStream | ||
475 | /// </summary> | ||
476 | /// <param name="path"></param> | ||
477 | /// <returns></returns> | ||
478 | private Stream GetStream(string path) | ||
479 | { | ||
480 | if (File.Exists(path)) | ||
481 | { | ||
482 | return new FileStream(path, FileMode.Open, FileAccess.Read); | ||
483 | } | ||
484 | else | ||
485 | { | ||
486 | try | ||
487 | { | ||
488 | Uri uri = new Uri(path); | ||
489 | if (uri.Scheme == "file") | ||
490 | { | ||
491 | return new FileStream(uri.AbsolutePath, FileMode.Open, FileAccess.Read); | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | if (uri.Scheme != "http") | ||
496 | throw new Exception(String.Format("Unsupported URI scheme ({0})", path)); | ||
497 | |||
498 | // OK, now we know we have an HTTP URI to work with | ||
499 | |||
500 | return URIFetch(uri); | ||
501 | } | ||
502 | } | ||
503 | catch (UriFormatException) | ||
504 | { | ||
505 | // In many cases the user will put in a plain old filename that cannot be found so assume that | ||
506 | // this is the problem rather than confusing the issue with a UriFormatException | ||
507 | throw new Exception(String.Format("Cannot find file {0}", path)); | ||
508 | } | ||
509 | } | ||
510 | } | ||
511 | |||
512 | private static Stream URIFetch(Uri uri) | ||
513 | { | ||
514 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
515 | |||
516 | // request.Credentials = credentials; | ||
517 | |||
518 | request.ContentLength = 0; | ||
519 | request.KeepAlive = false; | ||
520 | |||
521 | WebResponse response = request.GetResponse(); | ||
522 | Stream file = response.GetResponseStream(); | ||
523 | |||
524 | // justincc: gonna ignore the content type for now and just try anything | ||
525 | //if (response.ContentType != "application/x-oar") | ||
526 | // throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString())); | ||
527 | |||
528 | if (response.ContentLength == 0) | ||
529 | throw new Exception(String.Format("{0} returned an empty file", uri.ToString())); | ||
530 | |||
531 | // return new BufferedStream(file, (int) response.ContentLength); | ||
532 | return new BufferedStream(file, 1000000); | ||
533 | } | ||
534 | |||
535 | /// <summary> | ||
536 | /// Load oar control file | 474 | /// Load oar control file |
537 | /// </summary> | 475 | /// </summary> |
538 | /// <param name="path"></param> | 476 | /// <param name="path"></param> |