gst/registries/gstxmlregistry.c (get_time)
authorColin Walters <walters@verbum.org>
Mon, 29 Mar 2004 22:17:28 +0000 (22:17 +0000)
committerColin Walters <walters@verbum.org>
Mon, 29 Mar 2004 22:17:28 +0000 (22:17 +0000)
Original commit message from CVS:
2004-03-29  Colin Walters  <walters@redhat.com>

* gst/registries/gstxmlregistry.c (get_time)
(plugin_times_older_than_recurse):
Use the result of stat to determine whether a path is a file,
so we don't attempt to opendir() files.

ChangeLog
gst/registries/gstxmlregistry.c

index 509f16f..078626f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-03-29  Colin Walters  <walters@redhat.com>
+
+       * gst/registries/gstxmlregistry.c (get_time)
+       (plugin_times_older_than_recurse):
+       Use the result of stat to determine whether a path is a file,
+       so we don't attempt to opendir() files.
+
 2004-03-29  Benjamin Otte  <otte@gnome.org>
 
        * gst/gstpad.c: (gst_pad_set_explicit_caps):
index 041c058..2bdb601 100644 (file)
@@ -283,12 +283,18 @@ gst_xml_registry_get_property (GObject * object, guint prop_id,
  * so this function returns the last time *anything* changed to this path
  */
 static time_t
-get_time (const char *path)
+get_time (const char *path, gboolean * is_dir)
 {
   struct stat statbuf;
 
-  if (stat (path, &statbuf))
+  if (stat (path, &statbuf)) {
+    *is_dir = FALSE;
     return 0;
+  }
+
+  if (is_dir)
+    *is_dir = S_ISDIR (statbuf.st_mode);
+
   if (statbuf.st_mtime > statbuf.st_ctime)
     return statbuf.st_mtime;
   return statbuf.st_ctime;
@@ -408,9 +414,10 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
 {
   DIR *dir;
   struct dirent *dirent;
+  gboolean is_dir;
   gchar *pluginname;
 
-  time_t pathtime = get_time (path);
+  time_t pathtime = get_time (path, &is_dir);
 
   if (pathtime > regtime) {
     GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
@@ -419,6 +426,9 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
     return FALSE;
   }
 
+  if (!is_dir)
+    return TRUE;
+
   dir = opendir (path);
   if (dir) {
     while ((dirent = readdir (dir))) {
@@ -490,7 +500,7 @@ gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
     /* at this point we know it exists */
     g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_READABLE, FALSE);
 
-    if (!plugin_times_older_than (paths, get_time (registry->location))) {
+    if (!plugin_times_older_than (paths, get_time (registry->location, NULL))) {
       if (gst_registry->flags & GST_REGISTRY_WRITABLE) {
         GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding...");
 
@@ -498,7 +508,8 @@ gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
 
         gst_registry_save (gst_registry);
 
-        if (!plugin_times_older_than (paths, get_time (registry->location))) {
+        if (!plugin_times_older_than (paths, get_time (registry->location,
+                    NULL))) {
           GST_CAT_INFO (GST_CAT_GST_INIT,
               "Registry still out of date, something is wrong...");
           return FALSE;