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

◆ GetFinalLinkTarget()

static string System.IO.FileSystem.GetFinalLinkTarget ( string linkPath,
bool isDirectory )
inlinestaticprivate

Definition at line 669 of file FileSystem.cs.

670 {
673 if ((findData.dwFileAttributes & 0x400) == 0 || (findData.dwReserved0 != 2684354572u && findData.dwReserved0 != 2684354563u))
674 {
675 return null;
676 }
678 {
679 if (safeFileHandle.IsInvalid)
680 {
683 {
685 }
686 throw Win32Marshal.GetExceptionForWin32Error(lastWin32Error, linkPath);
687 }
688 char[] array = ArrayPool<char>.Shared.Rent(4096);
689 try
690 {
691 uint num = GetFinalPathNameByHandle(safeFileHandle, array);
692 if (num > array.Length)
693 {
694 char[] array2 = array;
695 array = ArrayPool<char>.Shared.Rent((int)num);
696 ArrayPool<char>.Shared.Return(array2);
697 num = GetFinalPathNameByHandle(safeFileHandle, array);
698 }
699 if (num == 0)
700 {
701 throw Win32Marshal.GetExceptionForLastWin32Error(linkPath);
702 }
703 int num2 = ((!PathInternal.IsExtended(linkPath.AsSpan())) ? 4 : 0);
704 return new string(array, num2, (int)num - num2);
705 }
706 finally
707 {
708 ArrayPool<char>.Shared.Return(array);
709 }
710 }
711 string GetFinalLinkTargetSlow(string linkPath)
712 {
714 string result = null;
715 while (immediateLinkTarget != null)
716 {
717 result = immediateLinkTarget;
719 }
720 return result;
721 }
722 unsafe static uint GetFinalPathNameByHandle(SafeFileHandle handle, char[] buffer)
723 {
724 fixed (char* lpszFilePath = buffer)
725 {
727 }
728 }
729 }
static unsafe uint GetFinalPathNameByHandle(SafeFileHandle hFile, char *lpszFilePath, uint cchFilePath, uint dwFlags)
static unsafe string GetImmediateLinkTarget(string linkPath, bool isDirectory, bool throwOnError, bool returnFullPath)
static unsafe SafeFileHandle OpenSafeFileHandle(string path, int flags)
static void GetFindData(string fullPath, bool isDirectory, bool ignoreAccessDenied, ref Interop.Kernel32.WIN32_FIND_DATA findData)
static bool IsPathUnreachableError(int errorCode)
Definition FileSystem.cs:69

References System.array, System.buffer, System.IO.Win32Marshal.GetExceptionForLastWin32Error(), System.IO.Win32Marshal.GetExceptionForWin32Error(), Interop.Kernel32.GetFinalPathNameByHandle(), System.IO.FileSystem.GetFindData(), System.IO.FileSystem.GetImmediateLinkTarget(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.handle, System.IO.PathInternal.IsExtended(), System.IO.FileSystem.IsPathUnreachableError(), and System.IO.FileSystem.OpenSafeFileHandle().

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