: this (handle, access, ownsHandle, bufferSize, isAsync, false) {}
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
- internal FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool isZeroSize)
+ internal FileStream (IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool isConsoleWrapper)
{
if (handle == MonoIO.InvalidHandle)
throw new ArgumentException ("handle", Locale.GetText ("Invalid."));
- Init (new SafeFileHandle (handle, false), access, ownsHandle, bufferSize, isAsync, isZeroSize);
+ Init (new SafeFileHandle (handle, false), access, ownsHandle, bufferSize, isAsync, isConsoleWrapper);
}
// construct from filename
{
}
-#if !NET_2_1
public FileStream (SafeFileHandle handle, FileAccess access)
:this(handle, access, DefaultBufferSize, false)
{
Init (handle, access, false, bufferSize, isAsync, false);
}
+#if !MOBILE
[MonoLimitation ("This ignores the rights parameter")]
public FileStream (string path, FileMode mode,
FileSystemRights rights, FileShare share,
}
#endif
+ internal FileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, string msgPath, bool bFromProxy, bool useLongPath = false, bool checkHost = false)
+ : this (path, mode, access, share, bufferSize, false, options)
+ {
+ }
+
internal FileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool isAsync, bool anonymous)
: this (path, mode, access, share, bufferSize, anonymous, isAsync ? FileOptions.Asynchronous : FileOptions.None)
{
}
}
- private void Init (SafeFileHandle safeHandle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool isZeroSize)
+ private void Init (SafeFileHandle safeHandle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync, bool isConsoleWrapper)
{
+ if (!isConsoleWrapper && safeHandle.IsInvalid)
+ throw new ArgumentException(Environment.GetResourceString("Arg_InvalidHandle"), "handle");
if (access < FileAccess.Read || access > FileAccess.ReadWrite)
throw new ArgumentOutOfRangeException ("access");
+ if (!isConsoleWrapper && bufferSize <= 0)
+ throw new ArgumentOutOfRangeException("bufferSize", Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum"));
MonoIOError error;
MonoFileType ftype = MonoIO.GetFileType (safeHandle, out error);
return ret;
}
set {
- if(value < 0) {
- throw new ArgumentOutOfRangeException("Attempt to set the position to a negative value");
- }
-
+ if (value < 0) throw new ArgumentOutOfRangeException("value", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+
Seek (value, SeekOrigin.Begin);
}
}
result.BytesRead = -1;
result.Count = numBytes;
result.OriginalCount = numBytes;
-
+/*
if (buf_dirty) {
MemoryStream ms = new MemoryStream ();
FlushBuffer (ms);
array = ms.ToArray ();
numBytes = array.Length;
}
-
+*/
WriteDelegate w = WriteInternal;
return w.BeginInvoke (array, offset, numBytes, userCallback, stateObject);
}
if (count > 0) {
// Use the fastest method, all range checks has been done
- Buffer.BlockCopyInternal (buf, buf_offset, dest, dest_offset, count);
+ Buffer.InternalBlockCopy (buf, buf_offset, dest, dest_offset, count);
buf_offset += count;
}
return(count);
}
- void FlushBuffer (Stream st)
+ void FlushBuffer ()
{
if (buf_dirty) {
- MonoIOError error;
+// if (st == null) {
+ MonoIOError error;
- if (CanSeek == true && !isExposed) {
- MonoIO.Seek (safeHandle, buf_start, SeekOrigin.Begin, out error);
+ if (CanSeek == true && !isExposed) {
+ MonoIO.Seek (safeHandle, buf_start, SeekOrigin.Begin, out error);
- if (error != MonoIOError.ERROR_SUCCESS) {
- // don't leak the path information for isolated storage
- throw MonoIO.GetException (GetSecureFileName (name), error);
+ if (error != MonoIOError.ERROR_SUCCESS) {
+ // don't leak the path information for isolated storage
+ throw MonoIO.GetException (GetSecureFileName (name), error);
+ }
}
- }
- if (st == null) {
+
int wcount = buf_length;
int offset = 0;
while (wcount > 0){
wcount -= n;
offset += n;
}
- } else {
- st.Write (buf, 0, buf_length);
- }
+// } else {
+// st.Write (buf, 0, buf_length);
+// }
}
buf_start += buf_offset;
buf_dirty = false;
}
- private void FlushBuffer ()
- {
- FlushBuffer (null);
- }
-
private void FlushBufferIfDirty ()
{
if (buf_dirty)
- FlushBuffer (null);
+ FlushBuffer ();
}
private void RefillBuffer ()