Skip to content

Commit 5dabc7c

Browse files
committed
Simplification 1
1 parent 190b3f2 commit 5dabc7c

2 files changed

Lines changed: 2 additions & 38 deletions

File tree

Modules/posixmodule.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ find_data_to_file_info(WIN32_FIND_DATAW *pFileData,
20462046
}
20472047

20482048
static BOOL
2049-
attributes_from_dir(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION* info, ULONG *reparse_tag, struct _Py_stat_struct* result)
2049+
attributes_from_dir(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *reparse_tag)
20502050
{
20512051
HANDLE hFindFile;
20522052
WIN32_FIND_DATAW FileData;
@@ -2077,12 +2077,7 @@ attributes_from_dir(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION* info, ULONG *re
20772077
return FALSE;
20782078
}
20792079
FindClose(hFindFile);
2080-
2081-
#ifdef MS_WINDOWS_DESKTOP
20822080
find_data_to_file_info(&FileData, info, reparse_tag);
2083-
#else
2084-
_Py_find_data_to_stat(&FileData, result);
2085-
#endif
20862081
return TRUE;
20872082
}
20882083

@@ -2140,7 +2135,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
21402135
case ERROR_ACCESS_DENIED: /* Cannot sync or read attributes. */
21412136
case ERROR_SHARING_VIOLATION: /* It's a paging file. */
21422137
/* Try reading the parent directory. */
2143-
if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag, result)) {
2138+
if (!attributes_from_dir(path, &fileInfo, &tagInfo.ReparseTag)) {
21442139
/* Cannot read the parent directory. */
21452140
switch (GetLastError()) {
21462141
case ERROR_FILE_NOT_FOUND: /* File cannot be found */
@@ -2156,11 +2151,7 @@ win32_xstat_slow_impl(const wchar_t *path, struct _Py_stat_struct *result,
21562151
return -1;
21572152
}
21582153

2159-
#ifdef MS_WINDOWS_DESKTOP
21602154
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
2161-
#else
2162-
if (result->st_file_attributes & FILE_ATTRIBUTE_REPARSE_POINT) {
2163-
#endif
21642155
if (traverse ||
21652156
!IsReparseTagNameSurrogate(tagInfo.ReparseTag)) {
21662157
/* The stat call has to traverse but cannot, so fail. */
@@ -16721,14 +16712,10 @@ DirEntry_from_find_data(PyObject *module, path_t *path, WIN32_FIND_DATAW *dataW)
1672116712
goto error;
1672216713
}
1672316714

16724-
#ifdef MS_WINDOWS_DESKTOP
1672516715
BY_HANDLE_FILE_INFORMATION file_info;
1672616716
ULONG reparse_tag;
1672716717
find_data_to_file_info(dataW, &file_info, &reparse_tag);
1672816718
_Py_attribute_data_to_stat(&file_info, reparse_tag, NULL, NULL, &entry->win32_lstat);
16729-
#else
16730-
_Py_find_data_to_stat(dataW, &entry->win32_lstat);
16731-
#endif
1673216719

1673316720
/* ctime is only deprecated from 3.12, so we copy birthtime across */
1673416721
entry->win32_lstat.st_ctime = entry->win32_lstat.st_birthtime;

Python/fileutils.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,29 +1243,6 @@ _Py_stat_basic_info_to_stat(FILE_STAT_BASIC_INFORMATION *info,
12431243
}
12441244
}
12451245

1246-
void
1247-
_Py_find_data_to_stat(WIN32_FIND_DATAW* find_data, struct _Py_stat_struct* result)
1248-
{
1249-
memset(result, 0, sizeof(*result));
1250-
result->st_mode = attributes_to_mode(find_data->dwFileAttributes);
1251-
FILE_TIME_to_time_t_nsec(&find_data->ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
1252-
FILE_TIME_to_time_t_nsec(&find_data->ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
1253-
FILE_TIME_to_time_t_nsec(&find_data->ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
1254-
result->st_size = (((long long)find_data->nFileSizeHigh) << 32) | find_data->nFileSizeLow;
1255-
1256-
if (find_data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
1257-
result->st_reparse_tag = find_data->dwReserved0;
1258-
1259-
if (find_data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
1260-
find_data->dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
1261-
/* first clear the S_IFMT bits */
1262-
result->st_mode ^= (result->st_mode & S_IFMT);
1263-
/* now set the bits that make this a symlink */
1264-
result->st_mode |= S_IFLNK;
1265-
}
1266-
result->st_file_attributes = find_data->dwFileAttributes;
1267-
}
1268-
12691246
#endif
12701247

12711248
/* Return information about a file.

0 commit comments

Comments
 (0)