mirror of https://github.com/python/cpython
Closes #9445: Removes detection of GetFinalPathNameByHandle
This commit is contained in:
parent
ef42dae7fa
commit
2ea51c98db
|
@ -1437,31 +1437,6 @@ attributes_from_dir_w(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab GetFinalPathNameByHandle dynamically from kernel32 */
|
|
||||||
static int has_GetFinalPathNameByHandle = -1;
|
|
||||||
static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD,
|
|
||||||
DWORD);
|
|
||||||
static int
|
|
||||||
check_GetFinalPathNameByHandle()
|
|
||||||
{
|
|
||||||
HINSTANCE hKernel32;
|
|
||||||
DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD,
|
|
||||||
DWORD);
|
|
||||||
|
|
||||||
/* only recheck */
|
|
||||||
if (-1 == has_GetFinalPathNameByHandle)
|
|
||||||
{
|
|
||||||
hKernel32 = GetModuleHandleW(L"KERNEL32");
|
|
||||||
*(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
|
|
||||||
"GetFinalPathNameByHandleA");
|
|
||||||
*(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
|
|
||||||
"GetFinalPathNameByHandleW");
|
|
||||||
has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA &&
|
|
||||||
Py_GetFinalPathNameByHandleW;
|
|
||||||
}
|
|
||||||
return has_GetFinalPathNameByHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
get_target_path(HANDLE hdl, wchar_t **target_path)
|
get_target_path(HANDLE hdl, wchar_t **target_path)
|
||||||
{
|
{
|
||||||
|
@ -1470,8 +1445,8 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
|
||||||
|
|
||||||
/* We have a good handle to the target, use it to determine
|
/* We have a good handle to the target, use it to determine
|
||||||
the target path name (then we'll call lstat on it). */
|
the target path name (then we'll call lstat on it). */
|
||||||
buf_size = Py_GetFinalPathNameByHandleW(hdl, 0, 0,
|
buf_size = GetFinalPathNameByHandleW(hdl, 0, 0,
|
||||||
VOLUME_NAME_DOS);
|
VOLUME_NAME_DOS);
|
||||||
if(!buf_size)
|
if(!buf_size)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -1481,7 +1456,7 @@ get_target_path(HANDLE hdl, wchar_t **target_path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_length = Py_GetFinalPathNameByHandleW(hdl,
|
result_length = GetFinalPathNameByHandleW(hdl,
|
||||||
buf, buf_size, VOLUME_NAME_DOS);
|
buf, buf_size, VOLUME_NAME_DOS);
|
||||||
|
|
||||||
if(!result_length) {
|
if(!result_length) {
|
||||||
|
@ -1514,12 +1489,6 @@ win32_xstat_impl(const char *path, struct _Py_stat_struct *result,
|
||||||
wchar_t *target_path;
|
wchar_t *target_path;
|
||||||
const char *dot;
|
const char *dot;
|
||||||
|
|
||||||
if(!check_GetFinalPathNameByHandle()) {
|
|
||||||
/* If the OS doesn't have GetFinalPathNameByHandle, don't
|
|
||||||
traverse reparse point. */
|
|
||||||
traverse = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hFile = CreateFileA(
|
hFile = CreateFileA(
|
||||||
path,
|
path,
|
||||||
FILE_READ_ATTRIBUTES, /* desired access */
|
FILE_READ_ATTRIBUTES, /* desired access */
|
||||||
|
@ -1610,12 +1579,6 @@ win32_xstat_impl_w(const wchar_t *path, struct _Py_stat_struct *result,
|
||||||
wchar_t *target_path;
|
wchar_t *target_path;
|
||||||
const wchar_t *dot;
|
const wchar_t *dot;
|
||||||
|
|
||||||
if(!check_GetFinalPathNameByHandle()) {
|
|
||||||
/* If the OS doesn't have GetFinalPathNameByHandle, don't
|
|
||||||
traverse reparse point. */
|
|
||||||
traverse = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hFile = CreateFileW(
|
hFile = CreateFileW(
|
||||||
path,
|
path,
|
||||||
FILE_READ_ATTRIBUTES, /* desired access */
|
FILE_READ_ATTRIBUTES, /* desired access */
|
||||||
|
@ -4700,13 +4663,6 @@ os__getfinalpathname_impl(PyModuleDef *module, PyObject *path)
|
||||||
if (path_wchar == NULL)
|
if (path_wchar == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if(!check_GetFinalPathNameByHandle()) {
|
|
||||||
/* If the OS doesn't have GetFinalPathNameByHandle, return a
|
|
||||||
NotImplementedError. */
|
|
||||||
return PyErr_Format(PyExc_NotImplementedError,
|
|
||||||
"GetFinalPathNameByHandle not available on this platform");
|
|
||||||
}
|
|
||||||
|
|
||||||
hFile = CreateFileW(
|
hFile = CreateFileW(
|
||||||
path_wchar,
|
path_wchar,
|
||||||
0, /* desired access */
|
0, /* desired access */
|
||||||
|
@ -4722,7 +4678,7 @@ os__getfinalpathname_impl(PyModuleDef *module, PyObject *path)
|
||||||
|
|
||||||
/* We have a good handle to the target, use it to determine the
|
/* We have a good handle to the target, use it to determine the
|
||||||
target path name. */
|
target path name. */
|
||||||
buf_size = Py_GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT);
|
buf_size = GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT);
|
||||||
|
|
||||||
if(!buf_size)
|
if(!buf_size)
|
||||||
return win32_error_object("GetFinalPathNameByHandle", path);
|
return win32_error_object("GetFinalPathNameByHandle", path);
|
||||||
|
@ -4731,8 +4687,8 @@ os__getfinalpathname_impl(PyModuleDef *module, PyObject *path)
|
||||||
if(!target_path)
|
if(!target_path)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
||||||
result_length = Py_GetFinalPathNameByHandleW(hFile, target_path,
|
result_length = GetFinalPathNameByHandleW(hFile, target_path,
|
||||||
buf_size, VOLUME_NAME_DOS);
|
buf_size, VOLUME_NAME_DOS);
|
||||||
if(!result_length)
|
if(!result_length)
|
||||||
return win32_error_object("GetFinalPathNamyByHandle", path);
|
return win32_error_object("GetFinalPathNamyByHandle", path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue