+2003-06-30 Zoltan Varga <vargaz@freemail.hu>
+
+ * FileStream.cs (Dispose): Flush the buffer even if we don't own the
+ handle.
+ * FileStream.cs: Add a new constructor parameter to turn off buffering.
+ This is used by the Console.OpenStandard...() methods. Also fix
+ argument checking in InitBuffer(), so a zero buffer size is also
+ rejected.
+
2003-06-27 Dietmar Maurer <dietmar@ximian.com>
* Stream.cs: use async.delegate invoke
: this (handle, access, ownsHandle, bufferSize, false) {}\r
public FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
+ : this (handle, access, ownsHandle, bufferSize, isAsync, false) {}
+
+ internal FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool noBuffering)
{
if (access < FileAccess.Read || access > FileAccess.ReadWrite)
throw new ArgumentOutOfRangeException ("access");
} else {
this.canseek = false;
}
-
- InitBuffer (bufferSize);
+
+ InitBuffer (bufferSize, noBuffering);
/* Can't set append mode */
this.append_startpos=0;
throw new UnauthorizedAccessException ("Access to the path '" + Path.GetFullPath (name) + "' is denied.");
}
- InitBuffer (bufferSize);
+ InitBuffer (bufferSize, false);
/* Append streams can't be read (see FileMode
* docs)
}\r
protected virtual void Dispose (bool disposing) {
- if (owner && handle != MonoIO.InvalidHandle) {
+ if (handle != MonoIO.InvalidHandle) {
lock(this) {
FlushBuffer ();
}
- MonoIOError error;
+ if (owner) {
+ MonoIOError error;
- MonoIO.Close (handle, out error);
+ MonoIO.Close (handle, out error);
- handle = MonoIO.InvalidHandle;
+ handle = MonoIO.InvalidHandle;
+ }
}
canseek = false;
return(amount);
}
-
-
- private void InitBuffer (int size)\r
+
+ private void InitBuffer (int size, bool noBuffering)\r
{\r
- if (size < 0)\r
- throw new ArgumentOutOfRangeException ("Buffer size cannot be negative.");\r
- if (size < 8)\r
- size = 8;\r
- \r
+ if (noBuffering)
+ size = 0;
+ else {
+ if (size <= 0)
+ throw new ArgumentOutOfRangeException ("bufferSize", "Positive number required.");
+ if (size < 8)
+ size = 8;
+ }
+
buf = new byte [size];\r
buf_size = size;\r
buf_start = 0;\r