Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1150)

Side by Side Diff: Modules/posixmodule.c

Issue 12084: os.stat() on windows doesn't consider relative symlink
Patch Set: Created 6 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* POSIX module implementation */ 2 /* POSIX module implementation */
3 3
4 /* This file is also used for Windows NT/MS-Win and OS/2. In that case the 4 /* This file is also used for Windows NT/MS-Win and OS/2. In that case the
5 module actually calls itself 'nt' or 'os2', not 'posix', and a few 5 module actually calls itself 'nt' or 'os2', not 'posix', and a few
6 functions are either unimplemented or implemented differently. The source 6 functions are either unimplemented or implemented differently. The source
7 assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent 7 assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent
8 of the compiler used. Different compilers define their own feature 8 of the compiler used. Different compilers define their own feature
9 test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler 9 test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler
10 independent macro PYOS_OS2 should be defined. On OS/2 the default 10 independent macro PYOS_OS2 should be defined. On OS/2 the default
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 wchar_t *buf; 1095 wchar_t *buf;
1096 1096
1097 /* We have a good handle to the target, use it to determine 1097 /* We have a good handle to the target, use it to determine
1098 the target path name (then we'll call lstat on it). */ 1098 the target path name (then we'll call lstat on it). */
1099 buf_size = Py_GetFinalPathNameByHandleW(hdl, 0, 0, 1099 buf_size = Py_GetFinalPathNameByHandleW(hdl, 0, 0,
1100 VOLUME_NAME_DOS); 1100 VOLUME_NAME_DOS);
1101 if(!buf_size) 1101 if(!buf_size)
1102 return FALSE; 1102 return FALSE;
1103 1103
1104 buf = (wchar_t *)malloc((buf_size+1)*sizeof(wchar_t)); 1104 buf = (wchar_t *)malloc((buf_size+1)*sizeof(wchar_t));
1105 if (!buf) {
1106 SetLastError(ERROR_OUTOFMEMORY);
1107 return FALSE;
1108 }
1109
1105 result_length = Py_GetFinalPathNameByHandleW(hdl, 1110 result_length = Py_GetFinalPathNameByHandleW(hdl,
1106 buf, buf_size, VOLUME_NAME_DOS); 1111 buf, buf_size, VOLUME_NAME_DOS);
1107 1112
1108 if(!result_length) { 1113 if(!result_length) {
1109 free(buf); 1114 free(buf);
1110 return FALSE; 1115 return FALSE;
1111 } 1116 }
1112 1117
1113 if(!CloseHandle(hdl)) { 1118 if(!CloseHandle(hdl)) {
1114 free(buf); 1119 free(buf);
(...skipping 14 matching lines...) Expand all
1129 BOOL traverse) 1134 BOOL traverse)
1130 { 1135 {
1131 int code; 1136 int code;
1132 HANDLE hFile, hFile2; 1137 HANDLE hFile, hFile2;
1133 BY_HANDLE_FILE_INFORMATION info; 1138 BY_HANDLE_FILE_INFORMATION info;
1134 ULONG reparse_tag = 0; 1139 ULONG reparse_tag = 0;
1135 wchar_t *target_path; 1140 wchar_t *target_path;
1136 const char *dot; 1141 const char *dot;
1137 1142
1138 if(!check_GetFinalPathNameByHandle()) { 1143 if(!check_GetFinalPathNameByHandle()) {
1139 /* If the OS doesn't have GetFinalPathNameByHandle, return a 1144 /* If the OS doesn't have GetFinalPathNameByHandle, don't
1140 NotImplementedError. */ 1145 traverse reparse point. */
1141 PyErr_SetString(PyExc_NotImplementedError, 1146 traverse = FALSE;
1142 "GetFinalPathNameByHandle not available on this platform");
1143 return -1;
1144 } 1147 }
1145 1148
1146 hFile = CreateFileA( 1149 hFile = CreateFileA(
1147 path, 1150 path,
1148 FILE_READ_ATTRIBUTES, /* desired access */ 1151 FILE_READ_ATTRIBUTES, /* desired access */
1149 0, /* share mode */ 1152 0, /* share mode */
1150 NULL, /* security attributes */ 1153 NULL, /* security attributes */
1151 OPEN_EXISTING, 1154 OPEN_EXISTING,
1152 /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */ 1155 /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
1153 /* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink. 1156 /* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 BOOL traverse) 1230 BOOL traverse)
1228 { 1231 {
1229 int code; 1232 int code;
1230 HANDLE hFile, hFile2; 1233 HANDLE hFile, hFile2;
1231 BY_HANDLE_FILE_INFORMATION info; 1234 BY_HANDLE_FILE_INFORMATION info;
1232 ULONG reparse_tag = 0; 1235 ULONG reparse_tag = 0;
1233 wchar_t *target_path; 1236 wchar_t *target_path;
1234 const wchar_t *dot; 1237 const wchar_t *dot;
1235 1238
1236 if(!check_GetFinalPathNameByHandle()) { 1239 if(!check_GetFinalPathNameByHandle()) {
1237 /* If the OS doesn't have GetFinalPathNameByHandle, return a 1240 /* If the OS doesn't have GetFinalPathNameByHandle, don't
1238 NotImplementedError. */ 1241 traverse reparse point. */
1239 PyErr_SetString(PyExc_NotImplementedError, 1242 traverse = FALSE;
1240 "GetFinalPathNameByHandle not available on this platform");
1241 return -1;
1242 } 1243 }
1243 1244
1244 hFile = CreateFileW( 1245 hFile = CreateFileW(
1245 path, 1246 path,
1246 FILE_READ_ATTRIBUTES, /* desired access */ 1247 FILE_READ_ATTRIBUTES, /* desired access */
1247 0, /* share mode */ 1248 0, /* share mode */
1248 NULL, /* security attributes */ 1249 NULL, /* security attributes */
1249 OPEN_EXISTING, 1250 OPEN_EXISTING,
1250 /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */ 1251 /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
1251 /* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink. 1252 /* FILE_FLAG_OPEN_REPARSE_POINT does not follow the symlink.
(...skipping 7360 matching lines...) Expand 10 before | Expand all | Expand 10 after
8612 8613
8613 8614
8614 #endif /* __APPLE__ */ 8615 #endif /* __APPLE__ */
8615 return m; 8616 return m;
8616 8617
8617 } 8618 }
8618 8619
8619 #ifdef __cplusplus 8620 #ifdef __cplusplus
8620 } 8621 }
8621 #endif 8622 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7