From f8d4198b957fd451bb9885043a23d66b63c59ced Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 29 Mar 2004 22:17:28 +0000 Subject: [PATCH] gst/registries/gstxmlregistry.c (get_time) Original commit message from CVS: 2004-03-29 Colin Walters * 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 | 7 +++++++ gst/registries/gstxmlregistry.c | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 509f16faee..078626fff2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-03-29 Colin Walters + + * 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 * gst/gstpad.c: (gst_pad_set_explicit_caps): diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c index 041c0581b6..2bdb6015b4 100644 --- a/gst/registries/gstxmlregistry.c +++ b/gst/registries/gstxmlregistry.c @@ -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; -- 2.34.1