Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateCore()

static SafeMemoryMappedFileHandle System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore ( FileStream fileStream,
string mapName,
HandleInheritability inheritability,
MemoryMappedFileAccess access,
MemoryMappedFileOptions options,
long capacity )
inlinestaticprivate

Definition at line 409 of file MemoryMappedFile.cs.

410 {
411 SafeFileHandle safeFileHandle = fileStream?.SafeFileHandle;
412 global::Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributes = GetSecAttrs(inheritability);
413 if (fileStream != null)
414 {
415 VerifyMemoryMappedFileAccess(access, capacity, fileStream);
416 }
417 SafeMemoryMappedFileHandle safeMemoryMappedFileHandle = ((safeFileHandle != null) ? global::Interop.CreateFileMapping(safeFileHandle, ref securityAttributes, GetPageAccess(access) | (int)options, capacity, mapName) : global::Interop.CreateFileMapping(new IntPtr(-1), ref securityAttributes, GetPageAccess(access) | (int)options, capacity, mapName));
418 int lastPInvokeError = Marshal.GetLastPInvokeError();
419 if (!safeMemoryMappedFileHandle.IsInvalid)
420 {
421 if (lastPInvokeError == 183)
422 {
423 safeMemoryMappedFileHandle.Dispose();
424 throw System.IO.Win32Marshal.GetExceptionForWin32Error(lastPInvokeError);
425 }
426 return safeMemoryMappedFileHandle;
427 }
428 safeMemoryMappedFileHandle.Dispose();
429 throw System.IO.Win32Marshal.GetExceptionForWin32Error(lastPInvokeError);
430 }
SafeFileHandle(IntPtr preexistingHandle, bool ownsHandle)
static void VerifyMemoryMappedFileAccess(MemoryMappedFileAccess access, long capacity, FileStream fileStream)
static unsafe global::Interop.Kernel32.SECURITY_ATTRIBUTES GetSecAttrs(HandleInheritability inheritability)
static int GetPageAccess(MemoryMappedFileAccess access)
static Exception GetExceptionForWin32Error(int errorCode, string path="")

References System.capacity, System.Runtime.InteropServices.SafeHandle.Dispose(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), System.IO.MemoryMappedFiles.MemoryMappedFile.GetPageAccess(), System.IO.MemoryMappedFiles.MemoryMappedFile.GetSecAttrs(), Microsoft.Win32.SafeHandles.SafeMemoryMappedFileHandle.IsInvalid, System.options, System.IO.FileStream.SafeFileHandle, and System.IO.MemoryMappedFiles.MemoryMappedFile.VerifyMemoryMappedFileAccess().

Referenced by System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile(), System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile(), and System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew().