]> wimlib.net Git - wimlib/blobdiff - src/dentry.h
Minor fixes (this is now v1.0.0 by the way)
[wimlib] / src / dentry.h
index be0b058605c0a6e869cd9dfdfa0410454ce92fb8..8283b596bfb0ae84a213c2af2a85e58d16cace93 100644 (file)
@@ -10,7 +10,7 @@
 
 struct stat;
 struct lookup_table;
-typedef struct WIMStruct WIMStruct;
+struct WIMStruct;
 
 /* Size of the struct dentry up to and including the file_name_len. */
 #define WIM_DENTRY_DISK_SIZE    102
@@ -89,7 +89,9 @@ struct ads_entry {
  * entry to align the next one (or the next dentry) on an 8-byte boundary. */
 static inline u64 ads_entry_total_length(const struct ads_entry *entry)
 {
-       u64 len = WIM_ADS_ENTRY_DISK_SIZE + entry->stream_name_len + 2;
+       u64 len = WIM_ADS_ENTRY_DISK_SIZE;
+       if (entry->stream_name_len)
+               len += entry->stream_name_len + 2;
        return (len + 7) & ~7;
 }
 
@@ -97,7 +99,6 @@ static inline void destroy_ads_entry(struct ads_entry *entry)
 {
        FREE(entry->stream_name);
        FREE(entry->stream_name_utf8);
-       memset(entry, 0, sizeof(entry));
 }
 
 static inline bool ads_entry_has_name(const struct ads_entry *entry,
@@ -108,6 +109,15 @@ static inline bool ads_entry_has_name(const struct ads_entry *entry,
        return memcmp(entry->stream_name_utf8, name, name_len) == 0;
 }
 
+static inline bool ads_entries_have_same_name(const struct ads_entry *entry_1,
+                                             const struct ads_entry *entry_2)
+{
+       if (entry_1->stream_name_len != entry_2->stream_name_len)
+               return false;
+       return memcmp(entry_1->stream_name, entry_2->stream_name,
+                     entry_1->stream_name_len) == 0;
+}
+
 
 /* 
  * In-memory structure for a WIM directory entry (dentry).  There is a directory
@@ -155,7 +165,11 @@ struct dentry {
         * The length here includes the base directory entry on disk as well as
         * the long and short filenames.  It does NOT include any alternate
         * stream entries that may follow the directory entry, even though the
-        * size of those needs to be considered.
+        * size of those needs to be considered.  The length SHOULD be 8-byte
+        * aligned, although we don't require it to be.  We do require the
+        * length to be large enough to hold the file name(s) of the dentry;
+        * additionally, a warning is issued if this field is larger than the
+        * aligned size.
         */
        u64 length;
 
@@ -216,7 +230,7 @@ struct dentry {
         * Unfortunately, in some WIMs it is NOT the case that all dentries that
         * share this field are actually in the same hard link set, although the
         * WIMs that wimlib writes maintain this restriction. */
-       u64 hard_link;
+       u64 link_group_id;
 
        /* Number of alternate data streams associated with this file. */
        u16 num_ads;
@@ -277,11 +291,14 @@ struct dentry {
        /* List of dentries in the hard link set */
        struct list_head link_group_list;
 
+       union {
        /* List of dentries sharing the same lookup table entry */
-       struct stream_list_head lte_group_list;
+               struct stream_list_head lte_group_list;
+               struct list_head tmp_list;
+       };
 
        /* Path to extracted file on disk (used during extraction only)
-        * (malloc()ed buffer) */
+        * (malloc()ed buffer, or set the same as full_path_utf8) */
        char *extracted_file;
 };
 
@@ -297,6 +314,7 @@ extern void dentry_remove_ads(struct dentry *dentry, struct ads_entry *entry);
 extern const char *path_stream_name(const char *path);
 
 extern u64 dentry_total_length(const struct dentry *dentry);
+extern u64 dentry_correct_total_length(const struct dentry *dentry);
 
 extern void stbuf_to_dentry(const struct stat *stbuf, struct dentry *dentry);
 
@@ -322,8 +340,8 @@ extern void link_dentry(struct dentry *dentry, struct dentry *parent);
 extern int print_dentry(struct dentry *dentry, void *lookup_table);
 extern int print_dentry_full_path(struct dentry *entry, void *ignore);
 
-extern struct dentry *get_dentry(WIMStruct *w, const char *path);
-extern struct dentry *get_parent_dentry(WIMStruct *w, const char *path);
+extern struct dentry *get_dentry(struct WIMStruct *w, const char *path);
+extern struct dentry *get_parent_dentry(struct WIMStruct *w, const char *path);
 extern struct dentry *get_dentry_child_with_name(const struct dentry *dentry, 
                                                        const char *name);
 extern void dentry_update_all_timestamps(struct dentry *dentry);
@@ -349,6 +367,8 @@ extern void calculate_dir_tree_statistics(struct dentry *root,
 extern int read_dentry(const u8 metadata_resource[], u64 metadata_resource_len, 
                       u64 offset, struct dentry *dentry);
 
+extern int verify_dentry(struct dentry *dentry, void *wim);
+
 extern int read_dentry_tree(const u8 metadata_resource[], 
                            u64 metadata_resource_len, struct dentry *dentry);