+static inline struct lookup_table_entry *
+dentry_stream_lte_unresolved(const struct dentry *dentry, unsigned stream_idx,
+ const struct lookup_table *table)
+{
+ wimlib_assert(!dentry->resolved);
+ wimlib_assert(stream_idx <= dentry->num_ads);
+ if (!table)
+ return NULL;
+ if (stream_idx == 0)
+ return __lookup_resource(table, dentry->hash);
+ else
+ return __lookup_resource(table,
+ dentry->ads_entries[
+ stream_idx - 1].hash);
+}
+/*
+ * Returns the lookup table entry for stream @stream_idx of the dentry, 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 *
+dentry_stream_lte(const struct dentry *dentry, unsigned stream_idx,
+ const struct lookup_table *table)
+{
+ if (dentry->resolved)
+ return dentry_stream_lte_resolved(dentry, stream_idx);
+ else
+ return dentry_stream_lte_unresolved(dentry, stream_idx, table);
+}
+
+
+static inline const u8 *dentry_stream_hash_unresolved(const struct dentry *dentry,
+ unsigned stream_idx)
+{
+ wimlib_assert(!dentry->resolved);
+ wimlib_assert(stream_idx <= dentry->num_ads);
+ if (stream_idx == 0)
+ return dentry->hash;
+ else
+ return dentry->ads_entries[stream_idx - 1].hash;
+}
+
+static inline const u8 *dentry_stream_hash_resolved(const struct dentry *dentry,
+ unsigned stream_idx)
+{
+ struct lookup_table_entry *lte;
+ lte = dentry_stream_lte_resolved(dentry, stream_idx);
+ if (lte)
+ return lte->hash;
+ else
+ return NULL;
+}
+
+/*
+ * Returns the hash for stream @stream_idx of the dentry, 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 *dentry_stream_hash(const struct dentry *dentry,
+ unsigned stream_idx)
+{
+ if (dentry->resolved)
+ return dentry_stream_hash_resolved(dentry, stream_idx);
+ else
+ return dentry_stream_hash_unresolved(dentry, stream_idx);
+}
+
+static inline struct lookup_table_entry *
+dentry_first_lte_resolved(const struct dentry *dentry)
+{
+ struct lookup_table_entry *lte;
+ wimlib_assert(dentry->resolved);
+
+ for (unsigned i = 0; i <= dentry->num_ads; i++) {
+ lte = dentry_stream_lte_resolved(dentry, i);
+ if (lte)
+ return lte;
+ }
+ return NULL;
+}
+
+static inline struct lookup_table_entry *
+dentry_first_lte_unresolved(const struct dentry *dentry,
+ const struct lookup_table *table)
+{
+ struct lookup_table_entry *lte;
+ wimlib_assert(!dentry->resolved);
+
+ for (unsigned i = 0; i <= dentry->num_ads; i++) {
+ lte = dentry_stream_lte_unresolved(dentry, i, table);
+ if (lte)
+ return lte;
+ }
+ return NULL;
+}
+
+extern struct lookup_table_entry *
+dentry_first_lte(const struct dentry *dentry, const struct lookup_table *table);
+