@@ -1730,6 +1730,30 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
1730
1730
}
1731
1731
1732
1732
if (hFile != INVALID_HANDLE_VALUE ) {
1733
+ /* Handle types other than files on disk. */
1734
+ fileType = GetFileType (hFile );
1735
+ if (fileType != FILE_TYPE_DISK ) {
1736
+ if (fileType == FILE_TYPE_UNKNOWN && GetLastError () != 0 ) {
1737
+ retval = -1 ;
1738
+ goto cleanup ;
1739
+ }
1740
+ DWORD fileAttributes = GetFileAttributesW (path );
1741
+ memset (result , 0 , sizeof (* result ));
1742
+ if (fileAttributes != INVALID_FILE_ATTRIBUTES &&
1743
+ fileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
1744
+ /* \\.\pipe\ or \\.\mailslot\ */
1745
+ result -> st_mode = _S_IFDIR ;
1746
+ } else if (fileType == FILE_TYPE_CHAR ) {
1747
+ /* \\.\nul */
1748
+ result -> st_mode = _S_IFCHR ;
1749
+ } else if (fileType == FILE_TYPE_PIPE ) {
1750
+ /* \\.\pipe\spam */
1751
+ result -> st_mode = _S_IFIFO ;
1752
+ }
1753
+ /* FILE_TYPE_UNKNOWN, e.g. \\.\mailslot\waitfor.exe\spam */
1754
+ goto cleanup ;
1755
+ }
1756
+
1733
1757
/* Query the reparse tag, and traverse a non-link. */
1734
1758
if (!traverse ) {
1735
1759
if (!GetFileInformationByHandleEx (hFile , FileAttributeTagInfo ,
@@ -1765,30 +1789,6 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
1765
1789
}
1766
1790
}
1767
1791
1768
- fileType = GetFileType (hFile );
1769
- if (fileType != FILE_TYPE_DISK ) {
1770
- /* Handle file types other than files on disk. */
1771
- if (fileType == FILE_TYPE_UNKNOWN && GetLastError () != 0 ) {
1772
- retval = -1 ;
1773
- goto cleanup ;
1774
- }
1775
- DWORD fileAttributes = GetFileAttributesW (path );
1776
- memset (result , 0 , sizeof (* result ));
1777
- if (fileAttributes != INVALID_FILE_ATTRIBUTES &&
1778
- fileAttributes & FILE_ATTRIBUTE_DIRECTORY ) {
1779
- /* \\.\pipe\ or \\.\mailslot\ */
1780
- result -> st_mode = _S_IFDIR ;
1781
- } else if (fileType == FILE_TYPE_CHAR ) {
1782
- /* \\.\nul */
1783
- result -> st_mode = _S_IFCHR ;
1784
- } else if (fileType == FILE_TYPE_PIPE ) {
1785
- /* \\.\pipe\spam */
1786
- result -> st_mode = _S_IFIFO ;
1787
- }
1788
- /* FILE_TYPE_UNKNOWN, e.g. \\.\mailslot\waitfor.exe\spam */
1789
- goto cleanup ;
1790
- }
1791
-
1792
1792
if (!GetFileInformationByHandle (hFile , & fileInfo )) {
1793
1793
switch (GetLastError ()) {
1794
1794
case ERROR_INVALID_PARAMETER :
0 commit comments