-
Couldn't load subscription status.
- Fork 1k
Open
Description
Lines 127 to 195 in c048ad8
| IBOOL S_file_existsp(const char *inpath, IBOOL followp) { | |
| #ifdef WIN32 | |
| wchar_t *wpath; IBOOL res; | |
| WIN32_FILE_ATTRIBUTE_DATA filedata; | |
| if ((wpath = S_malloc_wide_pathname(inpath)) == NULL) { | |
| return 0; | |
| } else { | |
| res = GetFileAttributesExW(wpath, GetFileExInfoStandard, &filedata); | |
| free(wpath); | |
| return res; | |
| } | |
| #else /* WIN32 */ | |
| struct STATBUF statbuf; char *path; IBOOL res; | |
| path = S_malloc_pathname(inpath); | |
| res = (followp ? STAT(path, &statbuf) : LSTAT(path, &statbuf)) == 0; | |
| free(path); | |
| return res; | |
| #endif /* WIN32 */ | |
| } | |
| IBOOL S_file_regularp(const char *inpath, IBOOL followp) { | |
| #ifdef WIN32 | |
| wchar_t *wpath; IBOOL res; | |
| WIN32_FILE_ATTRIBUTE_DATA filedata; | |
| if ((wpath = S_malloc_wide_pathname(inpath)) == NULL) { | |
| return 0; | |
| } else { | |
| res = GetFileAttributesExW(wpath, GetFileExInfoStandard, &filedata) | |
| && (filedata.dwFileAttributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) == 0; | |
| free(wpath); | |
| return res; | |
| } | |
| #else /* WIN32 */ | |
| struct STATBUF statbuf; char *path; IBOOL res; | |
| path = S_malloc_pathname(inpath); | |
| res = (followp ? STAT(path, &statbuf) : LSTAT(path, &statbuf)) == 0 | |
| && (statbuf.st_mode & S_IFMT) == S_IFREG; | |
| free(path); | |
| return res; | |
| #endif /* WIN32 */ | |
| } | |
| IBOOL S_file_directoryp(const char *inpath, IBOOL followp) { | |
| #ifdef WIN32 | |
| wchar_t *wpath; IBOOL res; | |
| WIN32_FILE_ATTRIBUTE_DATA filedata; | |
| if ((wpath = S_malloc_wide_pathname(inpath)) == NULL) { | |
| return 0; | |
| } else { | |
| res = GetFileAttributesExW(wpath, GetFileExInfoStandard, &filedata) | |
| && filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; | |
| free(wpath); | |
| return res; | |
| } | |
| #else /* WIN32 */ | |
| struct STATBUF statbuf; char *path; IBOOL res; | |
| path = S_malloc_pathname(inpath); | |
| res = (followp ? STAT(path, &statbuf) : LSTAT(path, &statbuf)) == 0 | |
| && (statbuf.st_mode & S_IFMT) == S_IFDIR; | |
| free(path); | |
| return res; | |
| #endif /* WIN32 */ | |
| } |
In these implementations, followp is not used at all for Win32. This looks wrong, because Windows supports symbolic links similar enough to POSIX. There is no reason to keep the inconsistent behaviors. Further, the behavior is also not the default of POSIX, due to the fact that GetFileAttributesExW does not follow links (i.e. it is more like lstat but not stat). These gliches are not documented.
Metadata
Metadata
Assignees
Labels
No labels