]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
xpress-compress.c: Rename xpress_match => xpress_item
[wimlib] / src / dentry.c
index 9c32bcb68130bc2459dbc0ad8bbab0d740e80f45..68a5d925627a5ae925c2d0db40898657b4fdd80c 100644 (file)
@@ -197,9 +197,9 @@ dentry_min_len_with_names(u16 file_name_nbytes, u16 short_name_nbytes)
 {
        u64 length = sizeof(struct wim_dentry_on_disk);
        if (file_name_nbytes)
-               length += file_name_nbytes + 2;
+               length += (u32)file_name_nbytes + 2;
        if (short_name_nbytes)
-               length += short_name_nbytes + 2;
+               length += (u32)short_name_nbytes + 2;
        return length;
 }
 
@@ -266,7 +266,7 @@ ads_entry_total_length(const struct wim_ads_entry *entry)
 {
        u64 len = sizeof(struct wim_ads_entry_on_disk);
        if (entry->stream_name_nbytes)
-               len += entry->stream_name_nbytes + 2;
+               len += (u32)entry->stream_name_nbytes + 2;
        return (len + 7) & ~7;
 }
 
@@ -296,9 +296,9 @@ inode_needs_dummy_stream(const struct wim_inode *inode)
 }
 
 /* Calculate the total number of bytes that will be consumed when a WIM dentry
- * is written.  This includes the base dentry the name fields, any tagged items,
- * any alternate data stream entries.  Also includes all alignment bytes between
- * these parts.  */
+ * is written.  This includes the base dentry, the name fields, any tagged items,
+ * and any alternate data stream entries.  Also includes all alignment bytes
+ * between these parts.  */
 u64
 dentry_out_total_length(const struct wim_dentry *dentry)
 {
@@ -430,7 +430,6 @@ dentry_full_path(struct wim_dentry *dentry)
 static int
 dentry_calculate_subdir_offset(struct wim_dentry *dentry, void *_subdir_offset_p)
 {
-
        if (dentry_is_directory(dentry)) {
                u64 *subdir_offset_p = _subdir_offset_p;
                struct wim_dentry *child;
@@ -775,72 +774,6 @@ get_parent_dentry(WIMStruct *wim, const tchar *path,
        return get_dentry(wim, buf, case_type);
 }
 
-#ifdef WITH_FUSE
-/* Finds the dentry, lookup table entry, and stream index for a WIM file stream,
- * given a path name.
- *
- * Currently, lookups of this type are only needed if FUSE is enabled.  */
-int
-wim_pathname_to_stream(WIMStruct *wim,
-                      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(wim, path, WIMLIB_CASE_SENSITIVE);
-       if (p)
-               *p = T(':');
-       if (!dentry)
-               return -errno;
-
-       inode = dentry->d_inode;
-
-       if (!inode->i_resolved)
-               if (inode_resolve_streams(inode, wim->lookup_table, false))
-                       return -EIO;
-
-       if (!(lookup_flags & LOOKUP_FLAG_DIRECTORY_OK)
-             && inode_is_directory(inode))
-               return -EISDIR;
-
-       if (stream_name) {
-               struct wim_ads_entry *ads_entry;
-
-               ads_entry = inode_get_ads_entry(inode, stream_name);
-               if (!ads_entry)
-                       return -errno;
-
-               stream_idx = ads_entry - inode->i_ads_entries + 1;
-               lte = ads_entry->lte;
-       } else {
-               lte = inode_unnamed_stream_resolved(inode, &stream_idx);
-       }
-       if (dentry_ret)
-               *dentry_ret = dentry;
-       if (lte_ret)
-               *lte_ret = lte;
-       if (stream_idx_ret)
-               *stream_idx_ret = stream_idx;
-       return 0;
-}
-#endif /* WITH_FUSE  */
-
 /* Creates an unlinked directory entry. */
 int
 new_dentry(const tchar *name, struct wim_dentry **dentry_ret)
@@ -1275,7 +1208,7 @@ read_dentry(const u8 * restrict buf, size_t buf_len,
                        goto err_free_dentry;
                }
                dentry->file_name_nbytes = file_name_nbytes;
-               p += file_name_nbytes + 2;
+               p += (u32)file_name_nbytes + 2;
        }
 
        /* Read the short filename if present.  Note: if there is no short
@@ -1288,7 +1221,7 @@ read_dentry(const u8 * restrict buf, size_t buf_len,
                        goto err_free_dentry;
                }
                dentry->short_name_nbytes = short_name_nbytes;
-               p += short_name_nbytes + 2;
+               p += (u32)short_name_nbytes + 2;
        }
 
        /* Read extra data at end of dentry (but before alternate data stream
@@ -1472,12 +1405,7 @@ read_dentry_tree(const u8 *buf, size_t buf_len,
                {
                        WARNING("The root directory has a nonempty name; "
                                "removing it.");
-                       FREE(root->file_name);
-                       FREE(root->short_name);
-                       root->file_name = NULL;
-                       root->short_name = NULL;
-                       root->file_name_nbytes = 0;
-                       root->short_name_nbytes = 0;
+                       dentry_set_name(root, NULL);
                }
 
                if (unlikely(!dentry_is_directory(root))) {
@@ -1526,7 +1454,7 @@ write_ads_entry(const struct wim_ads_entry *ads_entry,
        p += sizeof(struct wim_ads_entry_on_disk);
        if (ads_entry->stream_name_nbytes) {
                p = mempcpy(p, ads_entry->stream_name,
-                           ads_entry->stream_name_nbytes + 2);
+                           (u32)ads_entry->stream_name_nbytes + 2);
        }
        /* Align to 8-byte boundary */
        while ((uintptr_t)p & 7)
@@ -1599,10 +1527,10 @@ write_dentry(const struct wim_dentry * restrict dentry, u8 * restrict p)
        wimlib_assert(dentry_is_root(dentry) != dentry_has_long_name(dentry));
 
        if (dentry_has_long_name(dentry))
-               p = mempcpy(p, dentry->file_name, dentry->file_name_nbytes + 2);
+               p = mempcpy(p, dentry->file_name, (u32)dentry->file_name_nbytes + 2);
 
        if (dentry_has_short_name(dentry))
-               p = mempcpy(p, dentry->short_name, dentry->short_name_nbytes + 2);
+               p = mempcpy(p, dentry->short_name, (u32)dentry->short_name_nbytes + 2);
 
        /* Align to 8-byte boundary */
        while ((uintptr_t)p & 7)