+ tfputs(T("WIM_RESHDR_FLAG_SPANNED, "), out);
+ tputc(T('\n'), out);
+ switch (lte->resource_location) {
+ case RESOURCE_IN_WIM:
+ if (lte->wim->filename) {
+ tfprintf(out, T("WIM file = `%"TS"'\n"),
+ lte->wim->filename);
+ }
+ break;
+#ifdef __WIN32__
+ case RESOURCE_WIN32:
+#endif
+ case RESOURCE_IN_FILE_ON_DISK:
+ tfprintf(out, T("File on Disk = `%"TS"'\n"),
+ lte->file_on_disk);
+ break;
+ case RESOURCE_IN_STAGING_FILE:
+ tfprintf(out, T("Staging File = `%"TS"'\n"),
+ lte->staging_file_name);
+ break;
+ default:
+ break;
+ }
+ tputc(T('\n'), out);
+}
+
+static int
+do_print_lookup_table_entry(struct wim_lookup_table_entry *lte, void *fp)
+{
+ print_lookup_table_entry(lte, (FILE*)fp);
+ return 0;
+}
+
+/*
+ * Prints the lookup table of a WIM file.
+ */
+WIMLIBAPI void
+wimlib_print_lookup_table(WIMStruct *w)
+{
+ for_lookup_table_entry(w->lookup_table,
+ do_print_lookup_table_entry,
+ stdout);
+}
+
+/* Given a SHA1 message digest, return the corresponding entry in the WIM's
+ * lookup table, or NULL if there is none. */
+struct wim_lookup_table_entry *
+__lookup_resource(const struct wim_lookup_table *table, const u8 hash[])
+{
+ size_t i;
+ struct wim_lookup_table_entry *lte;
+ struct hlist_node *pos;
+
+ wimlib_assert(table != NULL);
+ wimlib_assert(hash != NULL);
+
+ i = *(size_t*)hash % table->capacity;
+ hlist_for_each_entry(lte, pos, &table->array[i], hash_list)
+ if (hashes_equal(hash, lte->hash))
+ return lte;
+ return NULL;
+}
+
+#ifdef WITH_FUSE
+/*
+ * Finds the dentry, lookup table entry, and stream index for a WIM file stream,
+ * given a path name.
+ *
+ * This is only for pre-resolved inodes.
+ */
+int
+lookup_resource(WIMStruct *w,
+ const tchar *path,
+ int lookup_flags,
+ struct wim_dentry **dentry_ret,
+ struct wim_lookup_table_entry **lte_ret,
+ u16 *stream_idx_ret)
+{
+ struct wim_dentry *dentry;
+ struct wim_lookup_table_entry *lte;
+ u16 stream_idx;
+ const tchar *stream_name = NULL;
+ struct wim_inode *inode;
+ tchar *p = NULL;
+
+ if (lookup_flags & LOOKUP_FLAG_ADS_OK) {
+ stream_name = path_stream_name(path);
+ if (stream_name) {
+ p = (tchar*)stream_name - 1;
+ *p = T('\0');
+ }
+ }
+
+ dentry = get_dentry(w, path);
+ if (p)
+ *p = T(':');
+ if (!dentry)
+ return -errno;
+
+ inode = dentry->d_inode;
+
+ wimlib_assert(inode->i_resolved);
+
+ if (!(lookup_flags & LOOKUP_FLAG_DIRECTORY_OK)
+ && inode_is_directory(inode))
+ return -EISDIR;
+
+ if (stream_name) {
+ struct wim_ads_entry *ads_entry;
+ u16 ads_idx;
+ ads_entry = inode_get_ads_entry(inode, stream_name,
+ &ads_idx);
+ if (ads_entry) {
+ stream_idx = ads_idx + 1;
+ lte = ads_entry->lte;
+ goto out;
+ } else {
+ return -ENOENT;
+ }
+ } else {
+ lte = inode->i_lte;
+ stream_idx = 0;
+ }
+out:
+ if (dentry_ret)
+ *dentry_ret = dentry;
+ if (lte_ret)
+ *lte_ret = lte;
+ if (stream_idx_ret)
+ *stream_idx_ret = stream_idx;