]> wimlib.net Git - wimlib/blobdiff - src/unix_apply.c
Refactor headers
[wimlib] / src / unix_apply.c
index c0f36643a5c7d97f1daa67c3df86b23bd09ffb56..6b3ede19e82778658a1af73aa8e36eed1fb66362 100644 (file)
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include "config.h"
+#ifndef __WIN32__
 
-#ifdef HAVE_UTIME_H
-#  include <utime.h>
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
 #endif
+
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <unistd.h>
+#ifdef HAVE_UTIME_H
+#  include <utime.h>
+#endif
 
-#include "timestamp.h"
-#include "wimlib_internal.h"
-#include "lookup_table.h"
+#include "wimlib/apply.h"
+#include "wimlib/error.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/reparse.h"
+#include "wimlib/timestamp.h"
 
 /* Returns the number of components of @path.  */
 static unsigned
@@ -65,10 +71,10 @@ path_next_part(const char *path)
 }
 
 static int
-extract_regular_file_linked(struct wim_dentry *dentry,
-                           const char *output_path,
-                           struct apply_args *args,
-                           struct wim_lookup_table_entry *lte)
+unix_extract_regular_file_linked(struct wim_dentry *dentry,
+                                const char *output_path,
+                                struct apply_args *args,
+                                struct wim_lookup_table_entry *lte)
 {
        /* This mode overrides the normal hard-link extraction and
         * instead either symlinks or hardlinks *all* identical files in
@@ -200,10 +206,10 @@ dir_apply_unix_data(const char *dir, const struct wimlib_unix_data *unix_data,
 }
 
 static int
-extract_regular_file_unlinked(struct wim_dentry *dentry,
-                             struct apply_args *args,
-                             const char *output_path,
-                             struct wim_lookup_table_entry *lte)
+unix_extract_regular_file_unlinked(struct wim_dentry *dentry,
+                                  struct apply_args *args,
+                                  const char *output_path,
+                                  struct wim_lookup_table_entry *lte)
 {
        /* Normal mode of extraction.  Regular files and hard links are
         * extracted in the way that they appear in the WIM. */
@@ -292,9 +298,9 @@ out:
 }
 
 static int
-extract_regular_file(struct wim_dentry *dentry,
-                    struct apply_args *args,
-                    const char *output_path)
+unix_extract_regular_file(struct wim_dentry *dentry,
+                         struct apply_args *args,
+                         const char *output_path)
 {
        struct wim_lookup_table_entry *lte;
        const struct wim_inode *inode = dentry->d_inode;
@@ -305,20 +311,22 @@ extract_regular_file(struct wim_dentry *dentry,
                                           WIMLIB_EXTRACT_FLAG_HARDLINK)))
        {
                if (lte->extracted_file) {
-                       return extract_regular_file_linked(dentry, output_path, args, lte);
+                       return unix_extract_regular_file_linked(dentry,
+                                                               output_path,
+                                                               args, lte);
                } else {
                        lte->extracted_file = STRDUP(output_path);
                        if (!lte->extracted_file)
                                return WIMLIB_ERR_NOMEM;
                }
        }
-       return extract_regular_file_unlinked(dentry, args, output_path, lte);
+       return unix_extract_regular_file_unlinked(dentry, args, output_path, lte);
 }
 
 static int
-extract_symlink(struct wim_dentry *dentry,
-               struct apply_args *args,
-               const char *output_path)
+unix_extract_symlink(struct wim_dentry *dentry,
+                    struct apply_args *args,
+                    const char *output_path)
 {
        char target[4096 + args->target_realpath_len];
        char *fixed_target;
@@ -372,8 +380,8 @@ extract_symlink(struct wim_dentry *dentry,
 }
 
 static int
-extract_directory(struct wim_dentry *dentry, const tchar *output_path,
-                 int extract_flags)
+unix_extract_directory(struct wim_dentry *dentry, const tchar *output_path,
+                      int extract_flags)
 {
        int ret;
        struct stat stbuf;
@@ -381,8 +389,6 @@ extract_directory(struct wim_dentry *dentry, const tchar *output_path,
        ret = tstat(output_path, &stbuf);
        if (ret == 0) {
                if (S_ISDIR(stbuf.st_mode)) {
-                       /*if (!is_root)*/
-                               /*WARNING("`%s' already exists", output_path);*/
                        goto dir_exists;
                } else {
                        ERROR("`%"TS"' is not a directory", output_path);
@@ -425,11 +431,11 @@ unix_do_apply_dentry(const char *output_path, size_t output_path_len,
        const struct wim_inode *inode = dentry->d_inode;
 
        if (inode_is_symlink(inode))
-               return extract_symlink(dentry, args, output_path);
+               return unix_extract_symlink(dentry, args, output_path);
        else if (inode_is_directory(inode))
-               return extract_directory(dentry, output_path, args->extract_flags);
+               return unix_extract_directory(dentry, output_path, args->extract_flags);
        else
-               return extract_regular_file(dentry, args, output_path);
+               return unix_extract_regular_file(dentry, args, output_path);
 }
 
 int
@@ -491,3 +497,5 @@ unix_do_apply_dentry_timestamps(const char *output_path,
        }
        return 0;
 }
+
+#endif /* !__WIN32__ */