+
+/*
+ * find_dcache():
+ * Check if there is an existing dcache object matching our
+ * criteria.
+ */
+struct dcache *find_dcache(const char * const cwd, const char * const pattern,
+ const struct list_options * const lo)
+{
+ struct dcache *d = NULL, *next = first_dcache->next_dcache;
+ struct stat buf;
+
+ if (stat(cwd, &buf) > -1) {
+ /* run through the linked list */
+ while (next != NULL) {
+ d = next;
+ next = d->next_dcache;
+
+ if (buf.st_mtime <= d->generated &&
+ strcmp(d->dir_name, cwd) == 0 &&
+ strcmp(d->pattern, pattern) == 0 &&
+ memcmp(&(d->lo), lo, sizeof(struct list_options)) == 0) {
+ return d;
+ }
+ }
+ }
+ return NULL;
+}