You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -73,12 +73,12 @@ namespace System.IO
|
||||
: 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
|
||||
@@ -113,7 +113,6 @@ namespace System.IO
|
||||
{
|
||||
}
|
||||
|
||||
#if !NET_2_1
|
||||
public FileStream (SafeFileHandle handle, FileAccess access)
|
||||
:this(handle, access, DefaultBufferSize, false)
|
||||
{
|
||||
@@ -130,6 +129,7 @@ namespace System.IO
|
||||
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,
|
||||
@@ -291,10 +291,14 @@ namespace System.IO
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -411,10 +415,8 @@ namespace System.IO
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -51,6 +51,8 @@ namespace System.IO
|
||||
public static readonly IntPtr
|
||||
InvalidHandle = (IntPtr)(-1L);
|
||||
|
||||
static bool dump_handles = Environment.GetEnvironmentVariable ("MONO_DUMP_HANDLES_ON_ERROR_TOO_MANY_OPEN_FILES") != null;
|
||||
|
||||
// error methods
|
||||
public static Exception GetException (MonoIOError error)
|
||||
{
|
||||
@@ -89,6 +91,8 @@ namespace System.IO
|
||||
return new FileNotFoundException (message, path);
|
||||
|
||||
case MonoIOError.ERROR_TOO_MANY_OPEN_FILES:
|
||||
if (dump_handles)
|
||||
DumpHandles ();
|
||||
return new IOException ("Too many open files", unchecked((int)0x80070000) | (int)error);
|
||||
|
||||
case MonoIOError.ERROR_PATH_NOT_FOUND:
|
||||
@@ -572,11 +576,11 @@ namespace System.IO
|
||||
// pipe handles
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public extern static bool CreatePipe (out IntPtr read_handle, out IntPtr write_handle);
|
||||
public extern static bool CreatePipe (out IntPtr read_handle, out IntPtr write_handle, out MonoIOError error);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public extern static bool DuplicateHandle (IntPtr source_process_handle, IntPtr source_handle,
|
||||
IntPtr target_process_handle, out IntPtr target_handle, int access, int inherit, int options);
|
||||
IntPtr target_process_handle, out IntPtr target_handle, int access, int inherit, int options, out MonoIOError error);
|
||||
|
||||
// path characters
|
||||
|
||||
@@ -601,7 +605,7 @@ namespace System.IO
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
public extern static int GetTempPath(out string path);
|
||||
extern static void DumpHandles ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -289,6 +289,7 @@ namespace System.IO {
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364963%28v=vs.85%29.aspx
|
||||
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern int GetFullPathName(string path, int numBufferChars, StringBuilder buffer, ref IntPtr lpFilePartOrNull);
|
||||
@@ -341,6 +342,7 @@ namespace System.IO {
|
||||
}
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
// insecure - do not call directly
|
||||
internal static string InsecureGetFullPath (string path)
|
||||
@@ -352,11 +354,11 @@ namespace System.IO {
|
||||
string msg = Locale.GetText ("The specified path is not of a legal form (empty).");
|
||||
throw new ArgumentException (msg);
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
// adjust for drives, i.e. a special case for windows
|
||||
if (Environment.IsRunningOnWindows)
|
||||
path = WindowsDriveAdjustment (path);
|
||||
|
||||
#endif
|
||||
// if the supplied path ends with a separator...
|
||||
char end = path [path.Length - 1];
|
||||
|
||||
|
Reference in New Issue
Block a user