struct content *first;
struct content **last;
} contents;
+ char exposed;
};
struct heap_queue {
static unsigned toi(const void *p, int n);
static inline void cache_add_entry(struct iso9660 *iso9660,
struct file_info *file);
+static inline void cache_add_to_next_of_parent(struct iso9660 *iso9660,
+ struct file_info *file);
static inline struct file_info *cache_get_entry(struct iso9660 *iso9660);
static void heap_add_entry(struct iso9660 *iso9660,
struct heap_queue *heap, struct file_info *file);
re->parent = file->parent;
re->parent->refcount++;
re->parent->subdirs++;
- cache_add_entry(iso9660, re);
+ cache_add_to_next_of_parent(iso9660, re);
return (1);
} else
/* This case is wrong pattern. */
/* Directory data has been read completely. */
iso9660->entry_bytes_remaining = 0;
iso9660->entry_sparse_offset = 0;
+ file->exposed = 1;
}
release_file(iso9660, file);
int count;
file = cache_get_entry(iso9660);
- if (file != NULL)
+ if (file != NULL) {
+ while (file->parent != NULL && !file->parent->exposed) {
+ /* If file's parent is not exposed, it's moved
+ * to next entry of its parent. */
+ cache_add_to_next_of_parent(iso9660, file);
+ file = cache_get_entry(iso9660);
+ }
return (file);
+ }
file = next_entry(iso9660);
if (file == NULL)
iso9660->cache_files.last = &(file->next);
}
+static inline void
+cache_add_to_next_of_parent(struct iso9660 *iso9660, struct file_info *file)
+{
+ file->next = file->parent->next;
+ file->parent->next = file;
+ file->refcount++;
+ if (iso9660->cache_files.last == &(file->parent->next))
+ iso9660->cache_files.last = &(file->next);
+}
+
static inline struct file_info *
cache_get_entry(struct iso9660 *iso9660)
{