]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
Refactor headers
[wimlib] / src / dentry.c
index 1d367bfe06e6d5a4e7260173d11240ad945bd380..d77603feeebcf23aecbfc4c02c90d55469839818 100644 (file)
  * wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include "buffer_io.h"
-#include "dentry.h"
-#include "lookup_table.h"
-#include "timestamp.h"
-#include "wimlib_internal.h"
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "wimlib.h"
+#include "wimlib/buffer_io.h"
+#include "wimlib/dentry.h"
+#include "wimlib/encoding.h"
+#include "wimlib/error.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/metadata.h"
+#include "wimlib/resource.h"
+#include "wimlib/timestamp.h"
+
 #include <errno.h>
 
 /* Calculates the unaligned length, in bytes, of an on-disk WIM dentry that has
@@ -250,17 +259,16 @@ int
 for_dentry_in_tree(struct wim_dentry *root,
                   int (*visitor)(struct wim_dentry*, void*), void *arg)
 {
-       int ret = 0;
+       int ret;
 
-       if (root) {
-               int ret = visitor(root, arg);
-               if (ret == 0) {
-                       ret = for_dentry_tree_in_rbtree(root->d_inode->i_children.rb_node,
-                                                       visitor,
-                                                       arg);
-               }
-       }
-       return ret;
+       if (!root)
+               return 0;
+       ret = (*visitor)(root, arg);
+       if (ret)
+               return ret;
+       return for_dentry_tree_in_rbtree(root->d_inode->i_children.rb_node,
+                                        visitor,
+                                        arg);
 }
 
 /* Like for_dentry_in_tree(), but the visitor function is always called on a
@@ -269,14 +277,15 @@ int
 for_dentry_in_tree_depth(struct wim_dentry *root,
                         int (*visitor)(struct wim_dentry*, void*), void *arg)
 {
-       int ret = 0;
-       if (root) {
-               ret = for_dentry_tree_in_rbtree_depth(root->d_inode->i_children.rb_node,
-                                                     visitor, arg);
-               if (ret == 0)
-                       ret = visitor(root, arg);
-       }
-       return ret;
+       int ret;
+
+       if (!root)
+               return 0;
+       ret = for_dentry_tree_in_rbtree_depth(root->d_inode->i_children.rb_node,
+                                             visitor, arg);
+       if (ret)
+               return ret;
+       return (*visitor)(root, arg);
 }
 
 /* Calculate the full path of @dentry.  The full path of its parent must have
@@ -713,7 +722,7 @@ dentry_common_init(struct wim_dentry *dentry)
 }
 
 struct wim_inode *
-new_timeless_inode()
+new_timeless_inode(void)
 {
        struct wim_inode *inode = CALLOC(1, sizeof(struct wim_inode));
        if (inode) {
@@ -735,7 +744,7 @@ new_timeless_inode()
 }
 
 static struct wim_inode *
-new_inode()
+new_inode(void)
 {
        struct wim_inode *inode = new_timeless_inode();
        if (inode) {
@@ -1301,11 +1310,6 @@ replace_forbidden_characters(utf16lechar *name)
                if (*p == cpu_to_le16('/'))
        #endif
                {
-               #ifdef __WIN32__
-                       *p = cpu_to_le16(0xfffd);
-               #else
-                       *p = cpu_to_le16('?');
-               #endif
                        if (name) {
                                WARNING("File, directory, or stream name \"%"WS"\"\n"
                                        "          contains forbidden characters; "
@@ -1313,6 +1317,11 @@ replace_forbidden_characters(utf16lechar *name)
                                        name);
                                name = NULL;
                        }
+               #ifdef __WIN32__
+                       *p = cpu_to_le16(0xfffd);
+               #else
+                       *p = cpu_to_le16('?');
+               #endif
                }
        }
 }