+2009-11-03 Miguel de Icaza <miguel@novell.com>
+
+ * FileStream.cs: Check the return value of MonoIO.Write and handle
+ short-writes as those can happen when a FileStream is used on top
+ of a pipe on Unix.
+
+ Fixes bug: #531613, this should be backported to 2-4 and 2-6 after
+ some testing.
+
2009-10-29 Sebastien Pouliot <sebastien@ximian.com>
* FileStream.cs: Reduce code duplication by merging FillBuffer
MonoIOError error;
FlushBuffer ();
-
- MonoIO.Write (handle, src, offset, count, out error);
- if (error != MonoIOError.ERROR_SUCCESS) {
- // don't leak the path information for isolated storage
- throw MonoIO.GetException (GetSecureFileName (name), error);
- }
+ int wcount = count;
+ while (wcount > 0){
+ int n = MonoIO.Write (handle, src, offset, wcount, out error);
+ if (error != MonoIOError.ERROR_SUCCESS)
+ throw MonoIO.GetException (GetSecureFileName (name), error);
+
+ wcount -= n;
+ offset += n;
+ }
buf_start += count;
} else {
}
}
if (st == null) {
- MonoIO.Write (handle, buf, 0,
- buf_length, out error);
-
- if (error != MonoIOError.ERROR_SUCCESS) {
- // don't leak the path information for isolated storage
- throw MonoIO.GetException (GetSecureFileName (name), error);
+ int wcount = buf_length;
+ int offset = 0;
+ while (wcount > 0){
+ int n = MonoIO.Write (handle, buf, 0, buf_length, out error);
+ if (error != MonoIOError.ERROR_SUCCESS) {
+ // don't leak the path information for isolated storage
+ throw MonoIO.GetException (GetSecureFileName (name), error);
+ }
+ wcount -= n;
+ offset += n;
}
} else {
st.Write (buf, 0, buf_length);