Set st_mode bits in _fstati64.
authorJuan Lang <juan_lang@yahoo.com>
Mon, 6 Dec 2004 16:14:09 +0000 (16:14 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 6 Dec 2004 16:14:09 +0000 (16:14 +0000)
dlls/msvcrt/file.c

index aa8ce1b0ba6c4e7d3982576aacbe14f30c000bad..72f31b0cd10537c528767152293d9a6d7cbcf11d 100644 (file)
@@ -994,7 +994,19 @@ int MSVCRT__fstati64(int fd, struct MSVCRT__stati64* buf)
     msvcrt_set_errno(ERROR_INVALID_PARAMETER);
     return -1;
   }
-  FIXME(":dwFileAttributes = %ld, mode set to 0\n",hfi.dwFileAttributes);
+  dw = GetFileType(hand);
+  buf->st_mode = S_IREAD;
+  if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+    buf->st_mode |= S_IWRITE;
+  /* interestingly, Windows never seems to set S_IFDIR */
+  if (dw == FILE_TYPE_CHAR)
+    buf->st_mode |= S_IFCHR;
+  else if (dw == FILE_TYPE_PIPE)
+    buf->st_mode |= S_IFIFO;
+  else
+    buf->st_mode |= S_IFREG;
+  TRACE(":dwFileAttributes = 0x%lx, mode set to 0x%x\n",hfi.dwFileAttributes,
+   buf->st_mode);
   buf->st_nlink = hfi.nNumberOfLinks;
   buf->st_size  = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
   RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);