Skip to content

Commit b701dce

Browse files
authored
gh-102765: Update ntpath.isdir/isfile/islink/exists to use GetFileInformationByName when available (GH-103485)
1 parent 8a0c7f1 commit b701dce

File tree

2 files changed

+209
-118
lines changed

2 files changed

+209
-118
lines changed

Include/internal/pycore_fileutils_windows.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ static inline BOOL _Py_GetFileInformationByName(
7575
return GetFileInformationByName(FileName, FileInformationClass, FileInfoBuffer, FileInfoBufferSize);
7676
}
7777

78+
static inline BOOL _Py_GetFileInformationByName_ErrorIsTrustworthy(int error)
79+
{
80+
switch(error) {
81+
case ERROR_FILE_NOT_FOUND:
82+
case ERROR_PATH_NOT_FOUND:
83+
case ERROR_NOT_READY:
84+
case ERROR_BAD_NET_NAME:
85+
case ERROR_BAD_NETPATH:
86+
case ERROR_BAD_PATHNAME:
87+
case ERROR_INVALID_NAME:
88+
case ERROR_FILENAME_EXCED_RANGE:
89+
return TRUE;
90+
case ERROR_NOT_SUPPORTED:
91+
return FALSE;
92+
}
93+
return FALSE;
94+
}
95+
7896
#endif
7997

8098
#endif

0 commit comments

Comments
 (0)