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

◆ CreateFile()

static unsafe SafeFileHandle Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile ( string fullPath,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options )
inlinestaticprivate

Definition at line 449 of file SafeFileHandle.cs.

450 {
452 if ((share & FileShare.Inheritable) != 0)
453 {
455 sECURITY_ATTRIBUTES2.nLength = (uint)sizeof(Interop.Kernel32.SECURITY_ATTRIBUTES);
456 sECURITY_ATTRIBUTES2.bInheritHandle = Interop.BOOL.TRUE;
458 }
459 int dwDesiredAccess = (((access & FileAccess.Read) == FileAccess.Read) ? int.MinValue : 0) | (((access & FileAccess.Write) == FileAccess.Write) ? 1073741824 : 0);
460 share &= ~FileShare.Inheritable;
461 if (mode == FileMode.Append)
462 {
463 mode = FileMode.OpenOrCreate;
464 }
465 int num = (int)options;
466 num |= 0x100000;
468 if (safeFileHandle.IsInvalid)
469 {
471 if (num2 == 3 && fullPath.Length == PathInternal.GetRootLength(fullPath))
472 {
473 num2 = 5;
474 }
476 }
477 safeFileHandle._path = fullPath;
478 safeFileHandle._fileOptions = options;
479 return safeFileHandle;
480 }
static unsafe SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile)
Definition Interop.cs:105
static int GetRootLength(ReadOnlySpan< char > path)
static Exception GetExceptionForWin32Error(int errorCode, string path="")
static readonly IntPtr Zero
Definition IntPtr.cs:18

References Interop.Kernel32.CreateFile(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), System.IO.PathInternal.GetRootLength(), System.options, and System.IntPtr.Zero.

Referenced by System.IO.FileSystemAclExtensions.CreateFileHandle(), Microsoft.Win32.SafeHandles.SafeFileHandle.Open(), and System.IO.FileSystemWatcher.StartRaisingEvents().