Commit 30771261 by Edward Thomson

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.
parent b8bdffb5
......@@ -35,9 +35,6 @@
*/
#define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE)
/* GetFinalPathNameByHandleW signature */
typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD);
unsigned long git_win32__createfile_sharemode =
FILE_SHARE_READ | FILE_SHARE_WRITE;
int git_win32__retries = 10;
......@@ -598,40 +595,13 @@ int p_getcwd(char *buffer_out, size_t size)
return 0;
}
/*
* Returns the address of the GetFinalPathNameByHandleW function.
* This function is available on Windows Vista and higher.
*/
static PFGetFinalPathNameByHandleW get_fpnbyhandle(void)
{
static PFGetFinalPathNameByHandleW pFunc = NULL;
PFGetFinalPathNameByHandleW toReturn = pFunc;
if (!toReturn) {
HMODULE hModule = GetModuleHandleW(L"kernel32");
if (hModule)
toReturn = (PFGetFinalPathNameByHandleW)GetProcAddress(hModule, "GetFinalPathNameByHandleW");
pFunc = toReturn;
}
assert(toReturn);
return toReturn;
}
static int getfinalpath_w(
git_win32_path dest,
const wchar_t *path)
{
PFGetFinalPathNameByHandleW pgfp = get_fpnbyhandle();
HANDLE hFile;
DWORD dwChars;
if (!pgfp)
return -1;
/* Use FILE_FLAG_BACKUP_SEMANTICS so we can open a directory. Do not
* specify FILE_FLAG_OPEN_REPARSE_POINT; we want to open a handle to the
* target of the link. */
......@@ -642,7 +612,7 @@ static int getfinalpath_w(
return -1;
/* Call GetFinalPathNameByHandle */
dwChars = pgfp(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED);
dwChars = GetFinalPathNameByHandleW(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED);
CloseHandle(hFile);
if (!dwChars || dwChars >= GIT_WIN_PATH_UTF16)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment