* 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
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) {
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';
}
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);
ret = dir_apply_unix_data(output_path, &unix_data,
extract_flags);
}
-#endif
return ret;
}
}
return 0;
}
+
+#endif /* !__WIN32__ */