mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)
This commit is contained in:
parent
e68806c712
commit
ed066481c7
3 changed files with 73 additions and 7 deletions
|
|
@ -1886,8 +1886,9 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
|
|||
HANDLE hFile;
|
||||
BY_HANDLE_FILE_INFORMATION fileInfo;
|
||||
FILE_BASIC_INFO basicInfo;
|
||||
FILE_BASIC_INFO *pBasicInfo = NULL;
|
||||
FILE_ID_INFO idInfo;
|
||||
FILE_ID_INFO *pIdInfo = &idInfo;
|
||||
FILE_ID_INFO *pIdInfo = NULL;
|
||||
FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
|
||||
DWORD fileType, error;
|
||||
BOOL isUnhandledTag = FALSE;
|
||||
|
|
@ -2038,14 +2039,17 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
|
|||
retval = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Successfully got FileBasicInfo, so we'll pass it along */
|
||||
pBasicInfo = &basicInfo;
|
||||
|
||||
if (GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, sizeof(idInfo))) {
|
||||
/* Successfully got FileIdInfo, so pass it along */
|
||||
pIdInfo = &idInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetFileInformationByHandleEx(hFile, FileIdInfo, &idInfo, sizeof(idInfo))) {
|
||||
/* Failed to get FileIdInfo, so do not pass it along */
|
||||
pIdInfo = NULL;
|
||||
}
|
||||
|
||||
_Py_attribute_data_to_stat(&fileInfo, tagInfo.ReparseTag, &basicInfo, pIdInfo, result);
|
||||
_Py_attribute_data_to_stat(&fileInfo, tagInfo.ReparseTag, pBasicInfo, pIdInfo, result);
|
||||
update_st_mode_from_path(path, fileInfo.dwFileAttributes, result);
|
||||
|
||||
cleanup:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue