default:
throw new Error();
}
long maxSize = length + position;
SafeFileHandle hFileMapping = CreateFileMapping(fs.get_SafeFileHandle(), IntPtr.Zero, fileProtect, (int)(maxSize >> 32), (int)maxSize, null);
int err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
if (hFileMapping.get_IsInvalid())
{
throw new IOException("Win32 error " + err);
}
IntPtr p = MapViewOfFile(hFileMapping, mapAccess, (int)(position >> 32), (int)position, IntPtr.op_Explicit(length));
err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
hFileMapping.Close();
if (p.Equals(IntPtr.Zero))
{
if (err == 8 /*ERROR_NOT_ENOUGH_MEMORY*/)
{
throw new OutOfMemoryError("Map failed");