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

◆ OpenHandle()

static SafeFileHandle System.IO.FileSystem.OpenHandle ( string fullPath,
bool asDirectory )
inlinestaticprivate

Definition at line 344 of file FileSystem.cs.

345 {
346 string text = fullPath.Substring(0, PathInternal.GetRootLength(fullPath.AsSpan()));
347 if (text == fullPath && text[1] == Path.VolumeSeparatorChar)
348 {
349 throw new ArgumentException(SR.Arg_PathIsVolume, "path");
350 }
351 SafeFileHandle safeFileHandle = Interop.Kernel32.CreateFile(fullPath, 1073741824, FileShare.ReadWrite | FileShare.Delete, FileMode.Open, asDirectory ? 33554432 : 0);
352 if (safeFileHandle.IsInvalid)
353 {
354 int num = Marshal.GetLastWin32Error();
355 if (!asDirectory && num == 3 && fullPath.Equals(Directory.GetDirectoryRoot(fullPath)))
356 {
357 num = 5;
358 }
359 throw Win32Marshal.GetExceptionForWin32Error(num, fullPath);
360 }
361 return safeFileHandle;
362 }
static unsafe SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile)
Definition Interop.cs:105

References System.SR.Arg_PathIsVolume, Interop.Kernel32.CreateFile(), System.IO.Directory.GetDirectoryRoot(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.IO.PathInternal.GetRootLength(), System.text, and System.IO.Path.VolumeSeparatorChar.

Referenced by System.IO.FileSystem.SetFileTime().