[gtk: 1/2] gtkiconcache: Use g_stat instead of fstat



commit e7c9e2060c014c8f0d4ea20dbac659d8ce2a2bd5
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Jun 2 20:31:33 2020 +0200

    gtkiconcache: Use g_stat instead of fstat
    
    stat/fstat aren't compatible with GStatBuf on Windows in all cases.
    Since we don't really need the file descriptor anyway here replace it with
    a g_stat call.
    
    This fixes a compiler warning with 64bit mingw.
    And lets us remove this scary ifdeffery.

 gtk/gtkiconcache.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)
---
diff --git a/gtk/gtkiconcache.c b/gtk/gtkiconcache.c
index e8d982a566..ada3d95c79 100644
--- a/gtk/gtkiconcache.c
+++ b/gtk/gtkiconcache.c
@@ -81,7 +81,6 @@ gtk_icon_cache_new_for_path (const gchar *path)
   GMappedFile *map;
 
   gchar *cache_filename;
-  gint fd = -1;
   GStatBuf st;
   GStatBuf path_st;
 
@@ -93,24 +92,7 @@ gtk_icon_cache_new_for_path (const gchar *path)
   if (g_stat (path, &path_st) < 0)
     goto done;
 
-  /* Open the file and map it into memory */
-  fd = g_open (cache_filename, O_RDONLY|_O_BINARY, 0);
-
-  if (fd < 0)
-    goto done;
-
-#ifdef G_OS_WIN32
-
-/* Bug 660730: _fstat32 is only defined in msvcrt80.dll+/VS 2005+ */
-/*             or possibly in the msvcrt.dll linked to by the Windows DDK */
-/*             (will need to check on the Windows DDK part later) */
-#if ((defined (_MSC_VER) && (_MSC_VER >= 1400 || __MSVCRT_VERSION__ >= 0x0800)) || defined 
(__MINGW64_VERSION_MAJOR)) && !defined(_WIN64)
-#undef fstat /* Just in case */
-#define fstat _fstat32
-#endif
-#endif
-
-  if (fstat (fd, &st) < 0 || st.st_size < 4)
+  if (g_stat (cache_filename, &st) < 0 || st.st_size < 4)
     goto done;
 
   /* Verify cache is uptodate */
@@ -154,8 +136,6 @@ gtk_icon_cache_new_for_path (const gchar *path)
 
  done:
   g_free (cache_filename);
-  if (fd >= 0)
-    close (fd);
 
   return cache;
 }


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