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
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/corlib/System.IO/StreamWriter.cs')
-rw-r--r--mcs/class/corlib/System.IO/StreamWriter.cs43
1 files changed, 35 insertions, 8 deletions
diff --git a/mcs/class/corlib/System.IO/StreamWriter.cs b/mcs/class/corlib/System.IO/StreamWriter.cs
index 4c51d0269be..1799d74e6e6 100644
--- a/mcs/class/corlib/System.IO/StreamWriter.cs
+++ b/mcs/class/corlib/System.IO/StreamWriter.cs
@@ -123,7 +123,7 @@ namespace System.IO {
else
mode = FileMode.Create;
- internalStream = new FileStream (path, mode, FileAccess.Write);
+ internalStream = new FileStream (path, mode, FileAccess.Write, FileShare.Read);
if (append)
internalStream.Position = internalStream.Length;
@@ -137,12 +137,16 @@ namespace System.IO {
get {
return iflush;
}
- set {
- if (DisposedAlready)
- throw new ObjectDisposedException("StreamWriter");
- iflush = value;
- }
- }
+ set {
+ if (DisposedAlready)
+ throw new ObjectDisposedException("StreamWriter");
+ iflush = value;
+
+ if (iflush) {
+ Flush ();
+ }
+ }
+ }
public virtual Stream BaseStream {
get {
@@ -245,6 +249,28 @@ namespace System.IO {
index += todo;
decode_pos += todo;
}
+ }
+
+ void LowLevelWrite (string s)
+ {
+ int count = s.Length;
+ int index = 0;
+ while (count > 0) {
+ int todo = decode_buf.Length - decode_pos;
+ if (todo == 0) {
+ Decode ();
+ todo = decode_buf.Length;
+ }
+ if (todo > count)
+ todo = count;
+
+ for (int i = 0; i < todo; i ++)
+ decode_buf [i + decode_pos] = s [i + index];
+
+ count -= todo;
+ index += todo;
+ decode_pos += todo;
+ }
}
public override void Write (char value)
@@ -278,7 +304,8 @@ namespace System.IO {
throw new ObjectDisposedException("StreamWriter");
if (value != null)
- LowLevelWrite (value.ToCharArray (), 0, value.Length);
+ LowLevelWrite (value);
+
if (iflush)
Flush ();
}