X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Funix_apply.c;h=b1d914827beec90c9ac3f6e69067cd19161eaaa9;hp=0b96055d8142afe916d35eb9eaab6cc75f2e615e;hb=d55cda59032e0abe5f71cd6f16ade943d2713fee;hpb=480d5f19a840f2b3dfef6c256819e9739e8e7a1d;ds=sidebyside diff --git a/src/unix_apply.c b/src/unix_apply.c index 0b96055d..b1d91482 100644 --- a/src/unix_apply.c +++ b/src/unix_apply.c @@ -21,11 +21,12 @@ * along with wimlib; if not, see http://www.gnu.org/licenses/. */ -#include "config.h" +#ifndef __WIN32__ -#ifdef HAVE_UTIME_H -# include +#ifdef HAVE_CONFIG_H +# include "config.h" #endif + #include #include #include @@ -33,10 +34,15 @@ #include #include #include +#ifdef HAVE_UTIME_H +# include +#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 @@ -89,8 +95,13 @@ unix_extract_regular_file_linked(struct wim_dentry *dentry, char *p; const char *p2; size_t i; + const struct wim_dentry *d; - num_path_components = get_num_path_components(dentry->_full_path) - 1; + num_path_components = 0; + for (d = dentry; d != args->extract_root; d = d->parent) + num_path_components++; + wimlib_assert(num_path_components > 0); + num_path_components--; num_output_dir_path_components = get_num_path_components(args->target); if (args->extract_flags & WIMLIB_EXTRACT_FLAG_MULTI_IMAGE) { @@ -333,7 +344,7 @@ unix_extract_symlink(struct wim_dentry *dentry, if (ret <= 0) { ERROR("Could not read the symbolic link from dentry `%s'", - dentry->_full_path); + dentry_full_path(dentry)); return WIMLIB_ERR_INVALID_DENTRY; } target[args->target_realpath_len + ret] = '\0'; @@ -374,37 +385,33 @@ unix_extract_symlink(struct wim_dentry *dentry, } static int -unix_extract_directory(struct wim_dentry *dentry, const tchar *output_path, +unix_extract_directory(struct wim_dentry *dentry, const char *output_path, int extract_flags) { int ret; struct stat stbuf; - ret = tstat(output_path, &stbuf); + ret = stat(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); + ERROR("\"%s\" is not a directory", output_path); return WIMLIB_ERR_MKDIR; } } else { if (errno != ENOENT) { - ERROR_WITH_ERRNO("Failed to stat `%"TS"'", output_path); + ERROR_WITH_ERRNO("Failed to stat \"%s\"", output_path); return WIMLIB_ERR_STAT; } } - if (tmkdir(output_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) - { - ERROR_WITH_ERRNO("Cannot create directory `%"TS"'", output_path); + if (mkdir(output_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + ERROR_WITH_ERRNO("Cannot create directory \"%s\"", output_path); return WIMLIB_ERR_MKDIR; } dir_exists: ret = 0; -#ifndef __WIN32__ if (extract_flags & WIMLIB_EXTRACT_FLAG_UNIX_DATA) { struct wimlib_unix_data unix_data; ret = inode_get_unix_data(dentry->d_inode, &unix_data, NULL); @@ -416,7 +423,6 @@ dir_exists: ret = dir_apply_unix_data(output_path, &unix_data, extract_flags); } -#endif return ret; } @@ -493,3 +499,5 @@ unix_do_apply_dentry_timestamps(const char *output_path, } return 0; } + +#endif /* !__WIN32__ */