appropriate Exceptions here instead.
* FileStream.cs (SetLength): Revert part of my last patch, we're
throwing ObjectDisposedException instead of IOException again.
svn path=/trunk/mcs/; revision=29123
public override void SetLength (long value)
{
CheckObjectDisposedException ();
+
+ if (value < 0)
+ throw new ArgumentOutOfRangeException ("value must be positive");
+
+ if (!m_stream.CanWrite && !m_stream.CanSeek)
+ throw new NotSupportedException ("the stream cannot seek nor write.");
+
+ if ((m_stream == null) || (!m_stream.CanRead && !m_stream.CanWrite))
+ throw new IOException ("the stream is not open");
+
m_stream.SetLength(value);
if (Position > value)
Position = value;
throw new ObjectDisposedException ("BufferedStream",
Locale.GetText ("Stream is closed"));
}
- }
+ }
}
}
+2004-06-09 Duncan Mak <duncan@ximian.com>
+
+ * BufferedStream.cs (SetLength): Add checks and throw the
+ appropriate Exceptions here instead.
+
+ * FileStream.cs (SetLength): Revert part of my last patch, we're
+ throwing ObjectDisposedException instead of IOException again.
+
2004-06-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* FileStream.cs: re-enabled ignoring broken pipe errors when reading.
public override void SetLength (long length)
{
- if(CanSeek == false) {
+ if (handle == MonoIO.InvalidHandle)
+ throw new ObjectDisposedException ("Stream has been closed");
+
+ if(CanSeek == false)
throw new NotSupportedException("The stream does not support seeking");
- }
- if(CanWrite == false) {
+ if(CanWrite == false)
throw new NotSupportedException("The stream does not support writing");
- }
- if(length < 0) {
+ if(length < 0)
throw new ArgumentOutOfRangeException("Length is less than 0");
- }
-
- if (handle == MonoIO.InvalidHandle)
- throw new IOException ("Stream has been closed");
Flush ();