wimlib_iterate_dir_tree(): iterate in default case order
authorEric Biggers <ebiggers3@gmail.com>
Wed, 28 Jan 2015 01:09:36 +0000 (19:09 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 28 Jan 2015 01:09:36 +0000 (19:09 -0600)
include/wimlib/dentry.h
src/iterate_dir.c

index 1d869eae023c4979b30d8efcf0a1c2e3e24a9117..05cb8c3f9d762b33981e7f98b5657afa2f202968 100644 (file)
@@ -153,16 +153,27 @@ for_dentry_in_tree(struct wim_dentry *root,
                   void *args);
 
 /* Iterate through each @child dentry of the @dir directory inode,
- * in sorted order (by case sensitive name).  */
-#define for_inode_child(child, dir)                                            \
-       avl_tree_for_each_in_order((child), (dir)->i_children,                  \
+ * in sorted order by case sensitive name.  */
+#define for_inode_child(child, dir)                                    \
+       avl_tree_for_each_in_order((child), (dir)->i_children,          \
                                   struct wim_dentry, d_index_node)
 
 /* Iterate through each @child dentry of the @parent dentry,
- * in sorted order (by case sensitive name).  */
+ * in sorted order by case sensitive name.  */
 #define for_dentry_child(child, parent) \
        for_inode_child((child), (parent)->d_inode)
 
+/* Iterate through each @child dentry of the @dir directory inode,
+ * in sorted order by case insensitive name.  */
+#define for_inode_child_case_insensitive(child, dir)                   \
+       avl_tree_for_each_in_order((child), (dir)->i_children_ci,       \
+                                  struct wim_dentry, d_index_node_ci)
+
+/* Iterate through each @child dentry of the @parent dentry,
+ * in sorted order by case insensitive name.  */
+#define for_dentry_child_case_insensitive(child, parent) \
+       for_inode_child_case_insensitive((child), (parent)->d_inode)
+
 /* Iterate through each @child dentry of the @dir directory inode,
  * in postorder (safe for freeing the child dentries).  */
 #define for_inode_child_postorder(child, dir)                          \
index 8e7f6cc3878d6c59c8229b20ee65c2dda795cc13..76bb2b3c2d9a28d8f1d841fe4115f02e18a18f99 100644 (file)
@@ -170,12 +170,22 @@ do_iterate_dir_tree(WIMStruct *wim,
                struct wim_dentry *child;
 
                ret = 0;
-               for_dentry_child(child, dentry) {
-                       ret = do_iterate_dir_tree(wim, child,
-                                                 flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN,
-                                                 cb, user_ctx);
-                       if (ret)
-                               break;
+               if (default_ignore_case) {
+                       for_dentry_child_case_insensitive(child, dentry) {
+                               ret = do_iterate_dir_tree(wim, child,
+                                                         flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN,
+                                                         cb, user_ctx);
+                               if (ret)
+                                       break;
+                       }
+               } else {
+                       for_dentry_child(child, dentry) {
+                               ret = do_iterate_dir_tree(wim, child,
+                                                         flags & ~WIMLIB_ITERATE_DIR_TREE_FLAG_CHILDREN,
+                                                         cb, user_ctx);
+                               if (ret)
+                                       break;
+                       }
                }
        }
 out_free_wimlib_dentry: