stripped_nchars = ret;
target = rpdata.substitute_name;
target_nchars = rpdata.substitute_name_nbytes / sizeof(utf16lechar);
- stripped_target = target + 6;
+ stripped_target = target + stripped_nchars;
stripped_target_nchars = target_nchars - stripped_nchars;
new_target = alloca((6 + extract_root_realpath_nchars +
static bool
path_is_root_of_drive(const wchar_t *path)
{
- if (!*path)
+ if (*path == L'\0')
return false;
+ if (!wcsncmp(path, L"\\\\?\\", 4))
+ path += 4;
+
if (*path != L'/' && *path != L'\\') {
if (*(path + 1) == L':')
path += 2;
/* Directories must be created with CreateDirectoryW(). Then the call
* to CreateFileW() will merely open the directory that was already
* created rather than creating a new file. */
- if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY &&
- !path_is_root_of_drive(path)) {
- if (!CreateDirectoryW(path, NULL)) {
- err = GetLastError();
- if (err != ERROR_ALREADY_EXISTS) {
- ERROR("Failed to create directory \"%ls\"",
- path);
- win32_error(err);
- return WIMLIB_ERR_MKDIR;
+ if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) {
+ if (!path_is_root_of_drive(path)) {
+ if (!CreateDirectoryW(path, NULL)) {
+ err = GetLastError();
+ if (err != ERROR_ALREADY_EXISTS) {
+ ERROR("Failed to create directory \"%ls\"",
+ path);
+ win32_error(err);
+ return WIMLIB_ERR_MKDIR;
+ }
}
+ DEBUG("Created directory \"%ls\"", path);
}
- DEBUG("Created directory \"%ls\"", path);
*creationDisposition_ret = OPEN_EXISTING;
}
if (inode->i_attributes & FILE_ATTRIBUTE_ENCRYPTED &&
return ret;
}
- if (dentry_has_short_name(dentry))
+ if (dentry_has_short_name(dentry) && !dentry->dos_name_invalid)
SetFileShortNameW(h, dentry->short_name);
else if (running_on_windows_7_or_later())
SetFileShortNameW(h, L"");
!(args->vol_flags & FILE_SUPPORTS_REPARSE_POINTS))
{
WARNING("Not extracting reparse point \"%ls\"", output_path);
+ dentry->not_extracted = 1;
} else {
/* Create the file, directory, or reparse point, and extract the
* data streams. */
/* Save extracted path for a later call to
* CreateHardLinkW() if this inode has multiple links.
* */
- inode->i_extracted_file = WSTRDUP(output_path);
+ inode->i_extracted_file = WCSDUP(output_path);
if (!inode->i_extracted_file)
return WIMLIB_ERR_NOMEM;
}
HANDLE h;
const struct wim_inode *inode = dentry->d_inode;
- if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT &&
- !(args->vol_flags & FILE_SUPPORTS_REPARSE_POINTS))
- {
- /* Skip reparse points not extracted */
- return 0;
- }
-
/* Windows doesn't let you change the timestamps of the root directory
* (at least on FAT, which is dumb but expected since FAT doesn't store
* any metadata about the root directory...) */