X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fwin32_apply.c;h=f022e1d0bb1d2646e9edf291f51badd0a66e792c;hp=ffee267c61bfdee2b4e8a9ae4289129e28ce23da;hb=d490e6e2a9cb3e421556ed3e50e0665ec955a418;hpb=d55cda59032e0abe5f71cd6f16ade943d2713fee diff --git a/src/win32_apply.c b/src/win32_apply.c index ffee267c..f022e1d0 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -482,9 +482,12 @@ do_win32_extract_encrypted_stream(const wchar_t *path, 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; @@ -598,18 +601,19 @@ win32_begin_extract_unnamed_stream(const struct wim_inode *inode, /* 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 && @@ -730,7 +734,7 @@ win32_finish_extract_stream(HANDLE h, const struct wim_dentry *dentry, 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""); @@ -1259,7 +1263,7 @@ win32_do_apply_dentry(const wchar_t *output_path, /* 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; }