+ wimlib_assert(!inode->resolved);
+ wimlib_assert(stream_idx <= inode->num_ads);
+ if (!table)
+ return NULL;
+ if (stream_idx == 0)
+ return __lookup_resource(table, inode->hash);
+ else
+ return __lookup_resource(table,
+ inode->ads_entries[
+ stream_idx - 1].hash);
+}
+/*
+ * Returns the lookup table entry for stream @stream_idx of the inode, where
+ * stream_idx = 0 means the default un-named file stream, and stream_idx >= 1
+ * corresponds to an alternate data stream.
+ *
+ * This works for both resolved and un-resolved dentries.
+ */
+static inline struct lookup_table_entry *
+inode_stream_lte(const struct inode *inode, unsigned stream_idx,
+ const struct lookup_table *table)
+{
+ if (inode->resolved)
+ return inode_stream_lte_resolved(inode, stream_idx);
+ else
+ return inode_stream_lte_unresolved(inode, stream_idx, table);
+}
+
+
+static inline const u8 *inode_stream_hash_unresolved(const struct inode *inode,
+ unsigned stream_idx)
+{
+ wimlib_assert(!inode->resolved);
+ wimlib_assert(stream_idx <= inode->num_ads);
+ if (stream_idx == 0)
+ return inode->hash;
+ else
+ return inode->ads_entries[stream_idx - 1].hash;
+}
+
+
+static inline const u8 *inode_stream_hash_resolved(const struct inode *inode,
+ unsigned stream_idx)
+{
+ struct lookup_table_entry *lte;
+ lte = inode_stream_lte_resolved(inode, stream_idx);
+ if (lte)
+ return lte->hash;
+ else
+ return zero_hash;
+}
+
+/*
+ * Returns the hash for stream @stream_idx of the inode, where stream_idx = 0
+ * means the default un-named file stream, and stream_idx >= 1 corresponds to an
+ * alternate data stream.
+ *
+ * This works for both resolved and un-resolved dentries.
+ */
+static inline const u8 *inode_stream_hash(const struct inode *inode,
+ unsigned stream_idx)
+{
+ if (inode->resolved)
+ return inode_stream_hash_resolved(inode, stream_idx);
+ else
+ return inode_stream_hash_unresolved(inode, stream_idx);
+}
+
+static inline u16 inode_stream_name_len(const struct inode *inode,
+ unsigned stream_idx)
+{
+ wimlib_assert(stream_idx <= inode->num_ads);
+ if (stream_idx == 0)
+ return 0;
+ else
+ return inode->ads_entries[stream_idx - 1].stream_name_len;
+}
+
+static inline struct lookup_table_entry *
+inode_unnamed_lte_resolved(const struct inode *inode)
+{
+ wimlib_assert(inode->resolved);
+ for (unsigned i = 0; i <= inode->num_ads; i++)
+ if (inode_stream_name_len(inode, i) == 0 &&
+ !is_zero_hash(inode_stream_hash_resolved(inode, i)))
+ return inode_stream_lte_resolved(inode, i);
+ return NULL;
+}
+
+static inline struct lookup_table_entry *
+inode_unnamed_lte_unresolved(const struct inode *inode,
+ const struct lookup_table *table)
+{
+ wimlib_assert(!inode->resolved);
+ for (unsigned i = 0; i <= inode->num_ads; i++)
+ if (inode_stream_name_len(inode, i) == 0 &&
+ !is_zero_hash(inode_stream_hash_unresolved(inode, i)))
+ return inode_stream_lte_unresolved(inode, i, table);
+ return NULL;