- if (dentry_is_directory(dentry))
- return 0;
-
- src_table_entry = wim_lookup_resource(src_wim, dentry);
- if (!src_table_entry)
- return 0;
-
- dest_table_entry = wim_lookup_resource(dest_wim, dentry);
- if (dest_table_entry) {
- dest_table_entry->refcnt++;
- } else {
- dest_table_entry = new_lookup_table_entry();
- if (!dest_table_entry) {
- ERROR("Could not allocate lookup table entry!\n");
- return WIMLIB_ERR_NOMEM;
+ wimlib_assert(!dentry->resolved);
+
+ for (unsigned i = 0; i < (unsigned)dentry->num_ads + 1; i++) {
+ struct lookup_table_entry *src_lte, *dest_lte;
+ src_lte = dentry_stream_lte_unresolved(dentry, i,
+ src_wim->lookup_table);
+ if (!src_lte)
+ continue;
+ dest_lte = dentry_stream_lte_unresolved(dentry, i,
+ dest_wim->lookup_table);
+ if (dest_lte) {
+ dest_lte->refcnt++;
+ } else {
+ dest_lte = new_lookup_table_entry();
+ if (!dest_lte)
+ return WIMLIB_ERR_NOMEM;
+ dest_lte->other_wim_fp = src_wim->fp;
+ dest_lte->other_wim_ctype =
+ wimlib_get_compression_type(src_wim);
+ memcpy(&dest_lte->resource_entry,
+ &src_lte->resource_entry,
+ sizeof(struct resource_entry));
+ copy_hash(dest_lte->hash,
+ dentry_stream_hash_unresolved(dentry, i));
+ lookup_table_insert(dest_wim->lookup_table, dest_lte);