|
|
@@ -1,34 +1,34 @@
|
|
|
-//
|
|
|
-// System.IO/FileStream.cs
|
|
|
-//
|
|
|
-// Authors:
|
|
|
-// Dietmar Maurer ([email protected])
|
|
|
-// Dan Lewis ([email protected])
|
|
|
-//
|
|
|
-// (C) 2001 Ximian, Inc. http://www.ximian.com
|
|
|
-//
|
|
|
-
|
|
|
-using System;
|
|
|
-using System.Runtime.CompilerServices;
|
|
|
+//
|
|
|
+// System.IO/FileStream.cs
|
|
|
+//
|
|
|
+// Authors:
|
|
|
+// Dietmar Maurer ([email protected])
|
|
|
+// Dan Lewis ([email protected])
|
|
|
+//
|
|
|
+// (C) 2001 Ximian, Inc. http://www.ximian.com
|
|
|
+//
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
using System.Runtime.InteropServices;
|
|
|
-
|
|
|
-// FIXME: emit the correct exceptions everywhere. add error handling.
|
|
|
-
|
|
|
-namespace System.IO
|
|
|
-{
|
|
|
-
|
|
|
- public class FileStream : Stream
|
|
|
- {
|
|
|
- // construct from handle
|
|
|
-
|
|
|
- public FileStream (IntPtr handle, FileAccess access)
|
|
|
- : this (handle, access, true, DefaultBufferSize, false) {}
|
|
|
-
|
|
|
- public FileStream (IntPtr handle, FileAccess access, bool ownsHandle)
|
|
|
- : this (handle, access, ownsHandle, DefaultBufferSize, false) {}
|
|
|
-
|
|
|
- public FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
|
|
|
- : this (handle, access, ownsHandle, bufferSize, false) {}
|
|
|
+
|
|
|
+// FIXME: emit the correct exceptions everywhere. add error handling.
|
|
|
+
|
|
|
+namespace System.IO
|
|
|
+{
|
|
|
+
|
|
|
+ public class FileStream : Stream
|
|
|
+ {
|
|
|
+ // construct from handle
|
|
|
+
|
|
|
+ public FileStream (IntPtr handle, FileAccess access)
|
|
|
+ : this (handle, access, true, DefaultBufferSize, false) {}
|
|
|
+
|
|
|
+ public FileStream (IntPtr handle, FileAccess access, bool ownsHandle)
|
|
|
+ : this (handle, access, ownsHandle, DefaultBufferSize, false) {}
|
|
|
+
|
|
|
+ public FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
|
|
|
+ : this (handle, access, ownsHandle, bufferSize, false) {}
|
|
|
|
|
|
public FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
|
|
|
: this (handle, access, ownsHandle, bufferSize, isAsync, false) {}
|
|
|
@@ -62,19 +62,19 @@ namespace System.IO
|
|
|
this.append_startpos=0;
|
|
|
}
|
|
|
|
|
|
- // construct from filename
|
|
|
-
|
|
|
+ // construct from filename
|
|
|
+
|
|
|
public FileStream (string name, FileMode mode)
|
|
|
- : this (name, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.Read, DefaultBufferSize, false) { }
|
|
|
-
|
|
|
- public FileStream (string name, FileMode mode, FileAccess access)
|
|
|
- : this (name, mode, access, FileShare.ReadWrite, DefaultBufferSize, false) { }
|
|
|
-
|
|
|
- public FileStream (string name, FileMode mode, FileAccess access, FileShare share)
|
|
|
- : this (name, mode, access, share, DefaultBufferSize, false) { }
|
|
|
-
|
|
|
- public FileStream (string name, FileMode mode, FileAccess access, FileShare share, int bufferSize)
|
|
|
- : this (name, mode, access, share, bufferSize, false) { }
|
|
|
+ : this (name, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.Read, DefaultBufferSize, false) { }
|
|
|
+
|
|
|
+ public FileStream (string name, FileMode mode, FileAccess access)
|
|
|
+ : this (name, mode, access, FileShare.ReadWrite, DefaultBufferSize, false) { }
|
|
|
+
|
|
|
+ public FileStream (string name, FileMode mode, FileAccess access, FileShare share)
|
|
|
+ : this (name, mode, access, share, DefaultBufferSize, false) { }
|
|
|
+
|
|
|
+ public FileStream (string name, FileMode mode, FileAccess access, FileShare share, int bufferSize)
|
|
|
+ : this (name, mode, access, share, bufferSize, false) { }
|
|
|
|
|
|
public FileStream (string name, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool isAsync)
|
|
|
{
|
|
|
@@ -171,21 +171,21 @@ namespace System.IO
|
|
|
InitBuffer (bufferSize, false);
|
|
|
}
|
|
|
|
|
|
- // properties
|
|
|
-
|
|
|
- public override bool CanRead {
|
|
|
- get {
|
|
|
- return access == FileAccess.Read ||
|
|
|
- access == FileAccess.ReadWrite;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public override bool CanWrite {
|
|
|
- get {
|
|
|
- return access == FileAccess.Write ||
|
|
|
- access == FileAccess.ReadWrite;
|
|
|
- }
|
|
|
- }
|
|
|
+ // properties
|
|
|
+
|
|
|
+ public override bool CanRead {
|
|
|
+ get {
|
|
|
+ return access == FileAccess.Read ||
|
|
|
+ access == FileAccess.ReadWrite;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool CanWrite {
|
|
|
+ get {
|
|
|
+ return access == FileAccess.Write ||
|
|
|
+ access == FileAccess.ReadWrite;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public override bool CanSeek {
|
|
|
get {
|
|
|
@@ -199,11 +199,11 @@ namespace System.IO
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public string Name {
|
|
|
- get {
|
|
|
- return name;
|
|
|
- }
|
|
|
- }
|
|
|
+ public string Name {
|
|
|
+ get {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public override long Length {
|
|
|
get {
|
|
|
@@ -481,12 +481,12 @@ namespace System.IO
|
|
|
//MonoIO.Flush (handle);
|
|
|
}
|
|
|
|
|
|
- public override void Close ()
|
|
|
- {
|
|
|
- Dispose (true);
|
|
|
- GC.SuppressFinalize (this); // remove from finalize queue
|
|
|
- }
|
|
|
-
|
|
|
+ public override void Close ()
|
|
|
+ {
|
|
|
+ Dispose (true);
|
|
|
+ GC.SuppressFinalize (this); // remove from finalize queue
|
|
|
+ }
|
|
|
+
|
|
|
[MonoTODO]
|
|
|
public virtual void Lock (long position, long length)
|
|
|
{
|
|
|
@@ -499,12 +499,12 @@ namespace System.IO
|
|
|
throw new NotImplementedException ();
|
|
|
}
|
|
|
|
|
|
- // protected
|
|
|
-
|
|
|
- ~FileStream ()
|
|
|
- {
|
|
|
- Dispose (false);
|
|
|
- }
|
|
|
+ // protected
|
|
|
+
|
|
|
+ ~FileStream ()
|
|
|
+ {
|
|
|
+ Dispose (false);
|
|
|
+ }
|
|
|
|
|
|
protected virtual void Dispose (bool disposing) {
|
|
|
if (handle != MonoIO.InvalidHandle) {
|
|
|
@@ -626,8 +626,8 @@ namespace System.IO
|
|
|
return(amount);
|
|
|
}
|
|
|
|
|
|
- private void InitBuffer (int size, bool noBuffering)
|
|
|
- {
|
|
|
+ private void InitBuffer (int size, bool noBuffering)
|
|
|
+ {
|
|
|
if (noBuffering)
|
|
|
size = 0;
|
|
|
else {
|
|
|
@@ -637,32 +637,32 @@ namespace System.IO
|
|
|
size = 8;
|
|
|
}
|
|
|
|
|
|
- buf = new byte [size];
|
|
|
- buf_size = size;
|
|
|
- buf_start = 0;
|
|
|
- buf_offset = buf_length = 0;
|
|
|
- buf_dirty = false;
|
|
|
- }
|
|
|
-
|
|
|
- // fields
|
|
|
-
|
|
|
- private static int DefaultBufferSize = 8192;
|
|
|
-
|
|
|
- private FileAccess access;
|
|
|
- private bool owner;
|
|
|
- private bool async;
|
|
|
+ buf = new byte [size];
|
|
|
+ buf_size = size;
|
|
|
+ buf_start = 0;
|
|
|
+ buf_offset = buf_length = 0;
|
|
|
+ buf_dirty = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // fields
|
|
|
+
|
|
|
+ private static int DefaultBufferSize = 8192;
|
|
|
+
|
|
|
+ private FileAccess access;
|
|
|
+ private bool owner;
|
|
|
+ private bool async;
|
|
|
private bool canseek;
|
|
|
private long append_startpos;
|
|
|
|
|
|
-
|
|
|
- private byte [] buf; // the buffer
|
|
|
- private int buf_size; // capacity in bytes
|
|
|
- private int buf_length; // number of valid bytes in buffer
|
|
|
- private int buf_offset; // position of next byte
|
|
|
- private bool buf_dirty; // true if buffer has been written to
|
|
|
- private long buf_start; // location of buffer in file
|
|
|
- private string name = "[Unknown]"; // name of file.
|
|
|
-
|
|
|
- IntPtr handle; // handle to underlying file
|
|
|
- }
|
|
|
+
|
|
|
+ private byte [] buf; // the buffer
|
|
|
+ private int buf_size; // capacity in bytes
|
|
|
+ private int buf_length; // number of valid bytes in buffer
|
|
|
+ private int buf_offset; // position of next byte
|
|
|
+ private bool buf_dirty; // true if buffer has been written to
|
|
|
+ private long buf_start; // location of buffer in file
|
|
|
+ private string name = "[Unknown]"; // name of file.
|
|
|
+
|
|
|
+ IntPtr handle; // handle to underlying file
|
|
|
+ }
|
|
|
}
|