Skip to content

Commit 3077126

Browse files
committed
win32: use GetFinalPathNameByHandle directly
Now that we've updated to WIN32_WINNT version of Vista or better, we don't need to dynamically load GetFinalPathNameByHandle and can simply invoke it directly.
1 parent b8bdffb commit 3077126

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

src/win32/posix_w32.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
*/
3636
#define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE)
3737

38-
/* GetFinalPathNameByHandleW signature */
39-
typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD);
40-
4138
unsigned long git_win32__createfile_sharemode =
4239
FILE_SHARE_READ | FILE_SHARE_WRITE;
4340
int git_win32__retries = 10;
@@ -598,40 +595,13 @@ int p_getcwd(char *buffer_out, size_t size)
598595
return 0;
599596
}
600597

601-
/*
602-
* Returns the address of the GetFinalPathNameByHandleW function.
603-
* This function is available on Windows Vista and higher.
604-
*/
605-
static PFGetFinalPathNameByHandleW get_fpnbyhandle(void)
606-
{
607-
static PFGetFinalPathNameByHandleW pFunc = NULL;
608-
PFGetFinalPathNameByHandleW toReturn = pFunc;
609-
610-
if (!toReturn) {
611-
HMODULE hModule = GetModuleHandleW(L"kernel32");
612-
613-
if (hModule)
614-
toReturn = (PFGetFinalPathNameByHandleW)GetProcAddress(hModule, "GetFinalPathNameByHandleW");
615-
616-
pFunc = toReturn;
617-
}
618-
619-
assert(toReturn);
620-
621-
return toReturn;
622-
}
623-
624598
static int getfinalpath_w(
625599
git_win32_path dest,
626600
const wchar_t *path)
627601
{
628-
PFGetFinalPathNameByHandleW pgfp = get_fpnbyhandle();
629602
HANDLE hFile;
630603
DWORD dwChars;
631604

632-
if (!pgfp)
633-
return -1;
634-
635605
/* Use FILE_FLAG_BACKUP_SEMANTICS so we can open a directory. Do not
636606
* specify FILE_FLAG_OPEN_REPARSE_POINT; we want to open a handle to the
637607
* target of the link. */
@@ -642,7 +612,7 @@ static int getfinalpath_w(
642612
return -1;
643613

644614
/* Call GetFinalPathNameByHandle */
645-
dwChars = pgfp(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED);
615+
dwChars = GetFinalPathNameByHandleW(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED);
646616
CloseHandle(hFile);
647617

648618
if (!dwChars || dwChars >= GIT_WIN_PATH_UTF16)

0 commit comments

Comments
 (0)