[glib] GLocalFile: Use _fstati64 rather than stat on Win32



commit 8b50e2f5475f9817baa358e2f638d0853e50ffb1
Author: Kean Johnston <kean johnston gmail com>
Date:   Fri Apr 15 10:15:04 2011 +0200

    GLocalFile: Use _fstati64 rather than stat on Win32
    
    We want this to get 64bit timestamps and file lenghts.

 gio/glocalfile.c             |   12 +++++++++---
 gio/glocalfileoutputstream.c |   12 +++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 9e4aace..84ba0e2 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1297,8 +1297,8 @@ g_local_file_read (GFile         *file,
 		   GError       **error)
 {
   GLocalFile *local = G_LOCAL_FILE (file);
-  int fd;
-  struct stat buf;
+  int fd, ret;
+  GLocalFileStat buf;
   
   fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
   if (fd == -1)
@@ -1312,7 +1312,13 @@ g_local_file_read (GFile         *file,
       return NULL;
     }
 
-  if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
+#ifdef G_OS_WIN32
+  ret = _fstati64 (fd, &buf);
+#else
+  ret = fstat (fd, &buf);
+#endif
+
+  if (ret == 0 && S_ISDIR (buf.st_mode))
     {
       close (fd);
       g_set_error_literal (error, G_IO_ERROR,
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index 40576a9..650550e 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -909,10 +909,16 @@ handle_overwrite_open (const char    *filename,
 	    )
 	  )
 	{
-	  struct stat tmp_statbuf;
-	  
+          GLocalFileStat tmp_statbuf;
+          int tres;
+
+#ifdef G_OS_WIN32
+          tres = _fstati64 (tmpfd, &tmp_statbuf);
+#else
+          tres = fstat (tmpfd, &tmp_statbuf);
+#endif
 	  /* Check that we really needed to change something */
-	  if (fstat (tmpfd, &tmp_statbuf) != 0 ||
+	  if (tres != 0 ||
 	      original_stat.st_uid != tmp_statbuf.st_uid ||
 	      original_stat.st_gid != tmp_statbuf.st_gid ||
 	      original_stat.st_mode != tmp_statbuf.st_mode)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]