int mingw_lstat(const char *file_name, struct stat *buf)
{
WIN32_FILE_ATTRIBUTE_DATA fdata;
+ WIN32_FIND_DATAW findbuf = { 0 };
wchar_t wfilename[MAX_PATH];
int wlen = xutftowcs_path(wfilename, file_name);
if (wlen < 0)
}
if (GetFileAttributesExW(wfilename, GetFileExInfoStandard, &fdata)) {
+ /* for reparse points, use FindFirstFile to get the reparse tag */
+ if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+ HANDLE handle = FindFirstFileW(wfilename, &findbuf);
+ if (handle == INVALID_HANDLE_VALUE)
+ goto error;
+ FindClose(handle);
+ }
buf->st_ino = 0;
buf->st_gid = 0;
buf->st_uid = 0;
filetime_to_timespec(&(fdata.ftLastWriteTime), &(buf->st_mtim));
filetime_to_timespec(&(fdata.ftCreationTime), &(buf->st_ctim));
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
- WIN32_FIND_DATAW findbuf;
- HANDLE handle = FindFirstFileW(wfilename, &findbuf);
- if (handle != INVALID_HANDLE_VALUE) {
- if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
- (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
- buf->st_mode = S_IFLNK | S_IREAD;
- if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
- buf->st_mode |= S_IWRITE;
- }
- FindClose(handle);
+ if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
+ (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
+ buf->st_mode = S_IFLNK | S_IREAD;
+ if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ buf->st_mode |= S_IWRITE;
}
}
return 0;
}
+error:
switch (GetLastError()) {
case ERROR_ACCESS_DENIED:
case ERROR_SHARING_VIOLATION: