Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2005-05-18 23:40:02 +0400
committerSebastien Pouliot <sebastien@ximian.com>2005-05-18 23:40:02 +0400
commit2b2e8bcdd96ab7b2c6c5df204830b086cdfa761d (patch)
treec7fa82e31ee1cd236b8e2957d1da987cdfefc20e /mcs
parent8146eafe1d5c34f88ec26668d89d92a973018547 (diff)
2005-05-18 Sebastien Pouliot <sebastien@ximian.com>
* DeflateStream.cs: Fixed some changed/missing exceptions. * GzipStream.cs: Renamed to GZipStream (from beta2). svn path=/trunk/mcs/; revision=44714
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System/System.IO.Compression/ChangeLog5
-rw-r--r--mcs/class/System/System.IO.Compression/DeflateStream.cs38
-rw-r--r--mcs/class/System/System.IO.Compression/GzipStream.cs31
3 files changed, 63 insertions, 11 deletions
diff --git a/mcs/class/System/System.IO.Compression/ChangeLog b/mcs/class/System/System.IO.Compression/ChangeLog
index a3b04dbc82f..39a75612cff 100644
--- a/mcs/class/System/System.IO.Compression/ChangeLog
+++ b/mcs/class/System/System.IO.Compression/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-18 Sebastien Pouliot <sebastien@ximian.com>
+
+ * DeflateStream.cs: Fixed some changed/missing exceptions.
+ * GzipStream.cs: Renamed to GZipStream (from beta2).
+
2004-12-03 Raja R Harinath <rharinath@novell.com>
* DeflateStream.cs, GzipStream.cs, CompressionMode.cs: Make class public.
diff --git a/mcs/class/System/System.IO.Compression/DeflateStream.cs b/mcs/class/System/System.IO.Compression/DeflateStream.cs
index 02b37ecc7f7..35b7ec0a539 100644
--- a/mcs/class/System/System.IO.Compression/DeflateStream.cs
+++ b/mcs/class/System/System.IO.Compression/DeflateStream.cs
@@ -68,7 +68,19 @@ namespace System.IO.Compression {
delegate int ReadMethod (byte[] array, int offset, int count);
delegate void WriteMethod(byte[] array, int offset, int count);
- internal DeflateStream (Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip) {
+ internal DeflateStream (Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip)
+ {
+ if (compressedStream == null)
+ throw new ArgumentNullException ("compressedStream");
+
+ switch (mode) {
+ case CompressionMode.Compress:
+ case CompressionMode.Decompress:
+ break;
+ default:
+ throw new ArgumentException ("mode");
+ }
+
this.compressedStream = compressedStream;
this.mode = mode;
this.leaveOpen = leaveOpen;
@@ -96,7 +108,7 @@ namespace System.IO.Compression {
public override void Close () {
FlushInternal (true);
- if (mode == CompressionMode.Decompress && compressedStream.CanSeek) {
+ if (/*mode == CompressionMode.Decompress &&*/ compressedStream.CanSeek) {
int avail_in = z_stream_get_avail_in (z_stream);
if (avail_in != 0) {
compressedStream.Seek (- avail_in, SeekOrigin.Current);
@@ -115,7 +127,6 @@ namespace System.IO.Compression {
}
private int ReadInternal(byte[] array, int offset, int count) {
-
int buffer_size;
if (finished)
return 0;
@@ -173,10 +184,12 @@ namespace System.IO.Compression {
public override int Read (byte[] dest, int dest_offset, int count)
{
+ if (!open)
+ throw new ObjectDisposedException ("DeflateStream");
if (dest == null)
throw new ArgumentNullException ("Destination array is null.");
if (!CanRead)
- throw new NotSupportedException ("Stream does not support reading.");
+ throw new InvalidOperationException ("Stream does not support reading.");
int len = dest.Length;
if (dest_offset < 0 || count < 0)
throw new ArgumentException ("Dest or count is negative.");
@@ -231,6 +244,9 @@ namespace System.IO.Compression {
public override void Write (byte[] src, int src_offset, int count)
{
+ if (!open)
+ throw new ObjectDisposedException ("DeflateStream");
+
if (src == null)
throw new ArgumentNullException ("src");
@@ -246,7 +262,11 @@ namespace System.IO.Compression {
WriteInternal (src, src_offset, count);
}
- private void FlushInternal (bool finish) {
+ private void FlushInternal (bool finish)
+ {
+ if (!open)
+ throw new ObjectDisposedException ("DeflateStream");
+
int avail_out;
ZReturnConsts ret_val;
@@ -289,6 +309,9 @@ namespace System.IO.Compression {
public override IAsyncResult BeginRead (byte [] buffer, int offset, int count,
AsyncCallback cback, object state)
{
+ if (!open)
+ throw new ObjectDisposedException ("DeflateStream");
+
if (!CanRead)
throw new NotSupportedException ("This stream does not support reading");
@@ -311,8 +334,11 @@ namespace System.IO.Compression {
public override IAsyncResult BeginWrite (byte [] buffer, int offset, int count,
AsyncCallback cback, object state)
{
+ if (!open)
+ throw new ObjectDisposedException ("DeflateStream");
+
if (!CanWrite)
- throw new NotSupportedException ("This stream does not support writing");
+ throw new InvalidOperationException ("This stream does not support writing");
if (buffer == null)
throw new ArgumentNullException ("buffer");
diff --git a/mcs/class/System/System.IO.Compression/GzipStream.cs b/mcs/class/System/System.IO.Compression/GzipStream.cs
index 8d5f64fd28f..52fcdb6e93f 100644
--- a/mcs/class/System/System.IO.Compression/GzipStream.cs
+++ b/mcs/class/System/System.IO.Compression/GzipStream.cs
@@ -1,11 +1,31 @@
/* -*- Mode: csharp; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
//
-// GzipStream.cs
+// GZipStream.cs
//
// Authors:
// Christopher James Lahey <clahey@ximian.com>
//
-// (c) 2004 Novell, Inc. <http://www.novell.com>
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+//
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
@@ -15,15 +35,16 @@ using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
namespace System.IO.Compression {
- public class GzipStream : Stream
+
+ public class GZipStream : Stream
{
private DeflateStream deflateStream;
- public GzipStream (Stream compressedStream, CompressionMode mode) :
+ public GZipStream (Stream compressedStream, CompressionMode mode) :
this (compressedStream, mode, false) {
}
- public GzipStream (Stream compressedStream, CompressionMode mode, bool leaveOpen) {
+ public GZipStream (Stream compressedStream, CompressionMode mode, bool leaveOpen) {
this.deflateStream = new DeflateStream (compressedStream, mode, leaveOpen, true);
}