]> wimlib.net Git - wimlib/blobdiff - src/inode.c
New helper: inode_get_unnamed_data_stream()
[wimlib] / src / inode.c
index 62cab6ed0b0f3989772a09aafe11c432f43efb84..4b1b1d3eee8e108b3934ce5c6ba6f026cba7ac32 100644 (file)
@@ -59,6 +59,7 @@ new_inode(struct wim_dentry *dentry, bool set_timestamps)
        inode->i_not_rpfixed = 1;
        INIT_LIST_HEAD(&inode->i_list);
        INIT_LIST_HEAD(&inode->i_dentry);
+       inode->i_streams = inode->i_embedded_streams;
        if (set_timestamps) {
                u64 now = now_as_wim_timestamp();
                inode->i_creation_time = now;
@@ -437,7 +438,7 @@ inode_has_named_data_stream(const struct wim_inode *inode)
  *
  * If @force is %false:
  *     If any of the needed blobs do not exist in @table, return
- *     WIMLIB_ERR_RESOURCE_NOT_FOUND and leave the inode unmodified.
+ *     WIMLIB_ERR_RESOURCE_NOT_FOUND.
  * If @force is %true:
  *     If any of the needed blobs do not exist in @table, allocate new blob
  *     descriptors for them and insert them into @table.  This does not, of
@@ -452,14 +453,13 @@ int
 inode_resolve_streams(struct wim_inode *inode, struct blob_table *table,
                      bool force)
 {
-       struct blob_descriptor *blobs[inode->i_num_streams];
-
        for (unsigned i = 0; i < inode->i_num_streams; i++) {
+               struct wim_inode_stream *strm = &inode->i_streams[i];
 
-               if (inode->i_streams[i].stream_resolved)
+               if (strm->stream_resolved)
                        continue;
 
-               const u8 *hash = stream_hash(&inode->i_streams[i]);
+               const u8 *hash = stream_hash(strm);
                struct blob_descriptor *blob = NULL;
 
                if (!is_zero_hash(hash)) {
@@ -474,14 +474,8 @@ inode_resolve_streams(struct wim_inode *inode, struct blob_table *table,
                                blob_table_insert(table, blob);
                        }
                }
-               blobs[i] = blob;
-       }
-
-       for (unsigned i = 0; i < inode->i_num_streams; i++) {
-               if (!inode->i_streams[i].stream_resolved) {
-                       inode->i_streams[i]._stream_blob = blobs[i];
-                       inode->i_streams[i].stream_resolved = 1;
-               }
+               strm->_stream_blob = blob;
+               strm->stream_resolved = 1;
        }
        return 0;
 }
@@ -553,7 +547,7 @@ inode_get_blob_for_unnamed_data_stream(const struct wim_inode *inode,
 {
        const struct wim_inode_stream *strm;
 
-       strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA);
+       strm = inode_get_unnamed_data_stream(inode);
        if (!strm)
                return NULL;
 
@@ -567,7 +561,7 @@ inode_get_blob_for_unnamed_data_stream_resolved(const struct wim_inode *inode)
 {
        const struct wim_inode_stream *strm;
 
-       strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA);
+       strm = inode_get_unnamed_data_stream(inode);
        if (!strm)
                return NULL;
 
@@ -584,7 +578,7 @@ inode_get_hash_of_unnamed_data_stream(const struct wim_inode *inode)
 {
        const struct wim_inode_stream *strm;
 
-       strm = inode_get_unnamed_stream(inode, STREAM_TYPE_DATA);
+       strm = inode_get_unnamed_data_stream(inode);
        if (!strm)
                return zero_hash;