-LRN: w32 version of fstat
authorChristian Grothoff <christian@grothoff.org>
Thu, 15 Dec 2011 18:44:52 +0000 (18:44 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 15 Dec 2011 18:44:52 +0000 (18:44 +0000)
src/util/disk.c

index ba5d159e410391e5c57ed428814c5f9ea8f66641..0c9093fbc6077ed72fdf4fe1ff7952becd12ada1 100644 (file)
@@ -216,11 +216,23 @@ int
 GNUNET_DISK_file_handle_size (struct GNUNET_DISK_FileHandle *fh,
                              off_t *size)
 {
+#if WINDOWS
+  BOOL b;
+  LARGE_INTEGER li;
+  b = GetFileSizeEx (fh->h, &li);
+  if (!b)
+  {
+    SetErrnoFromWinError (GetLastError ());
+    return GNUNET_SYSERR;
+  }
+  *size = (off_t) li.QuadPart;
+#else
   struct stat sbuf;
 
   if (0 != FSTAT (fh->fd, &sbuf))
     return GNUNET_SYSERR;
   *size = sbuf.st_size;
+#endif
   return GNUNET_OK;
 }