gst/registries/gstxmlregistry.c (get_time)

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.
This commit is contained in:
Colin Walters 2004-03-29 22:17:28 +00:00
parent 097dc18c80
commit f8d4198b95
2 changed files with 23 additions and 5 deletions

View file

@ -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> 2004-03-29 Benjamin Otte <otte@gnome.org>
* gst/gstpad.c: (gst_pad_set_explicit_caps): * gst/gstpad.c: (gst_pad_set_explicit_caps):

View 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 * so this function returns the last time *anything* changed to this path
*/ */
static time_t static time_t
get_time (const char *path) get_time (const char *path, gboolean * is_dir)
{ {
struct stat statbuf; struct stat statbuf;
if (stat (path, &statbuf)) if (stat (path, &statbuf)) {
*is_dir = FALSE;
return 0; return 0;
}
if (is_dir)
*is_dir = S_ISDIR (statbuf.st_mode);
if (statbuf.st_mtime > statbuf.st_ctime) if (statbuf.st_mtime > statbuf.st_ctime)
return statbuf.st_mtime; return statbuf.st_mtime;
return statbuf.st_ctime; return statbuf.st_ctime;
@ -408,9 +414,10 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
{ {
DIR *dir; DIR *dir;
struct dirent *dirent; struct dirent *dirent;
gboolean is_dir;
gchar *pluginname; gchar *pluginname;
time_t pathtime = get_time (path); time_t pathtime = get_time (path, &is_dir);
if (pathtime > regtime) { if (pathtime > regtime) {
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
@ -419,6 +426,9 @@ plugin_times_older_than_recurse (gchar * path, time_t regtime)
return FALSE; return FALSE;
} }
if (!is_dir)
return TRUE;
dir = opendir (path); dir = opendir (path);
if (dir) { if (dir) {
while ((dirent = readdir (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 */ /* at this point we know it exists */
g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_READABLE, FALSE); 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) { if (gst_registry->flags & GST_REGISTRY_WRITABLE) {
GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding..."); 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); 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, GST_CAT_INFO (GST_CAT_GST_INIT,
"Registry still out of date, something is wrong..."); "Registry still out of date, something is wrong...");
return FALSE; return FALSE;