- 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, ptr) == 0 &&
- memcmp(&(d->lo), lo,
- sizeof(struct list_options)) == 0) {
- d->use_count++;
- f->dir_cache = d;
- f->file_data = d->dir_data;
- f->size = d->dir_size;
- f->dir_listing = 1;
- f->pos = 0;
- prepare_for_transfer(f);
- return;
- }
- }
+ struct dcache *d = find_dcache(cwd, ptr, lo);
+ if (d != NULL) {
+ d->use_count++;
+ f->dir_cache = d;
+ f->file_data = d->dir_data;
+ f->size = d->dir_size;
+ f->dir_listing = 1;
+ f->pos = 0;
+
+ prepare_for_transfer(f);
+ return;