[gimp] Bug 703113 - Plug-ins are queried on every launch



commit 767a5a321708c4ca19bbf1e103a3988fcc404cc5
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jul 12 15:18:38 2013 +0200

    Bug 703113 - Plug-ins are queried on every launch
    
    Port gimp_datafiles_read_directories() to GIO which seems to get
    its stat() calls right on all platforms.

 libgimpbase/Makefile.am     |    4 +-
 libgimpbase/gimpdatafiles.c |   65 +++++++++++++++++++++++++-----------------
 2 files changed, 41 insertions(+), 28 deletions(-)
---
diff --git a/libgimpbase/Makefile.am b/libgimpbase/Makefile.am
index 40e860c..59a258b 100644
--- a/libgimpbase/Makefile.am
+++ b/libgimpbase/Makefile.am
@@ -60,7 +60,7 @@ AM_CPPFLAGS = \
        -DG_LOG_DOMAIN=\"LibGimpBase\"                          \
        -DGIMP_BASE_COMPILATION                                 \
        -I$(top_srcdir)                                         \
-       $(GLIB_CFLAGS)                                          \
+       $(GIO_CFLAGS)                                           \
        $(BINRELOC_CFLAGS)                                      \
        -I$(includedir)                                         \
        $(xobjective_c)
@@ -162,7 +162,7 @@ libgimpbase_ GIMP_API_VERSION@_la_LDFLAGS = \
 libgimpbase_ GIMP_API_VERSION@_la_DEPENDENCIES = $(gimpbase_def)
 
 libgimpbase_ GIMP_API_VERSION@_la_LIBADD = \
-       $(GLIB_LIBS)    \
+       $(GIO_LIBS)     \
        $(ole32_lib)
 
 
diff --git a/libgimpbase/gimpdatafiles.c b/libgimpbase/gimpdatafiles.c
index ac7987c..0bf2520 100644
--- a/libgimpbase/gimpdatafiles.c
+++ b/libgimpbase/gimpdatafiles.c
@@ -21,20 +21,9 @@
 
 #include "config.h"
 
-#include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include <glib-object.h>
-#include <glib/gstdio.h>
-
-#ifdef G_OS_WIN32
-#include "gimpwin32-io.h"
-#endif /* G_OS_WIN32 */
+#include <gio/gio.h>
 
 #include "gimpbasetypes.h"
 
@@ -106,56 +95,80 @@ gimp_datafiles_read_directories (const gchar            *path_str,
 
           while ((dir_ent = g_dir_read_name (dir)))
             {
-              struct stat  filestat;
-              gchar       *filename;
+              gchar     *filename;
+              GFile     *file;
+              GFileInfo *info;
 
               if (is_hidden (dir_ent))
                 continue;
 
               filename = g_build_filename (dirname, dir_ent, NULL);
+              file = g_file_new_for_path (filename);
+
+              info = g_file_query_info (file,
+                                        G_FILE_ATTRIBUTE_STANDARD_TYPE      ","
+                                        G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE ","
+                                        "time::*",
+                                        G_FILE_QUERY_INFO_NONE,
+                                        NULL, NULL);
 
-              if (! g_stat (filename, &filestat))
+              if (info)
                 {
                   GimpDatafileData  file_data;
+                  GFileType         file_type;
 
                   file_data.filename = filename;
                   file_data.dirname  = dirname;
                   file_data.basename = dir_ent;
-                  file_data.atime    = filestat.st_atime;
-                  file_data.mtime    = filestat.st_mtime;
-                  file_data.ctime    = filestat.st_ctime;
+
+                  file_data.atime =
+                    g_file_info_get_attribute_uint64 (info,
+                                                      G_FILE_ATTRIBUTE_TIME_ACCESS);
+
+                  file_data.mtime =
+                    g_file_info_get_attribute_uint64 (info,
+                                                      G_FILE_ATTRIBUTE_TIME_MODIFIED);
+
+                  file_data.ctime =
+                    g_file_info_get_attribute_uint64 (info,
+                                                      G_FILE_ATTRIBUTE_TIME_CREATED);
+
+                  file_type =
+                    g_file_info_get_attribute_uint32 (info,
+                                                      G_FILE_ATTRIBUTE_STANDARD_TYPE);
 
                   if (flags & G_FILE_TEST_EXISTS)
                     {
                       (* loader_func) (&file_data, user_data);
                     }
                   else if ((flags & G_FILE_TEST_IS_REGULAR) &&
-                           S_ISREG (filestat.st_mode))
+                           (file_type == G_FILE_TYPE_REGULAR))
                     {
                       (* loader_func) (&file_data, user_data);
                     }
                   else if ((flags & G_FILE_TEST_IS_DIR) &&
-                           S_ISDIR (filestat.st_mode))
+                           (file_type == G_FILE_TYPE_DIRECTORY))
                     {
                       (* loader_func) (&file_data, user_data);
                     }
-#ifndef G_OS_WIN32
                   else if ((flags & G_FILE_TEST_IS_SYMLINK) &&
-                           S_ISLNK (filestat.st_mode))
+                           (file_type == G_FILE_TYPE_SYMBOLIC_LINK))
                     {
                       (* loader_func) (&file_data, user_data);
                     }
-#endif
                   else if ((flags & G_FILE_TEST_IS_EXECUTABLE) &&
-                           (((filestat.st_mode & S_IXUSR) &&
-                             !S_ISDIR (filestat.st_mode)) ||
-                            (S_ISREG (filestat.st_mode) &&
+                           (g_file_info_get_attribute_boolean (info,
+                                                               G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) ||
+                            ((file_type == G_FILE_TYPE_REGULAR) &&
                              is_script (filename))))
                     {
                       (* loader_func) (&file_data, user_data);
                     }
+
+                  g_object_unref (info);
                 }
 
+              g_object_unref (file);
               g_free (filename);
             }
 


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