X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fextract.c;h=422cd9ccaf4a6ea8298dca84ccd44a4271f722f7;hb=edf0f7f5331e626b55819dcafa88e202cdb82a32;hp=bc769eec798d284f61ddee9f28fd006304b616bd;hpb=50407ddd59aa2d0906225a4526eaefbf6da8450f;p=wimlib diff --git a/src/extract.c b/src/extract.c index bc769eec..422cd9cc 100644 --- a/src/extract.c +++ b/src/extract.c @@ -1471,7 +1471,7 @@ extract_streams_from_pipe(struct apply_ctx *ctx) pwm_flags = PWM_ALLOW_WIM_HDR; if ((ctx->extract_flags & WIMLIB_EXTRACT_FLAG_RESUME)) pwm_flags |= PWM_SILENT_EOF; - memcpy(ctx->progress.extract.guid, ctx->wim->hdr.guid, WIM_GID_LEN); + memcpy(ctx->progress.extract.guid, ctx->wim->hdr.guid, WIM_GUID_LEN); ctx->progress.extract.part_number = ctx->wim->hdr.part_number; ctx->progress.extract.total_parts = ctx->wim->hdr.total_parts; if (ctx->progress_func) @@ -1561,12 +1561,12 @@ extract_streams_from_pipe(struct apply_ctx *ctx) if (part_number != ctx->progress.extract.part_number || total_parts != ctx->progress.extract.total_parts || memcmp(pwm_hdr.guid, ctx->progress.extract.guid, - WIM_GID_LEN)) + WIM_GUID_LEN)) { ctx->progress.extract.part_number = part_number; ctx->progress.extract.total_parts = total_parts; memcpy(ctx->progress.extract.guid, - pwm_hdr.guid, WIM_GID_LEN); + pwm_hdr.guid, WIM_GUID_LEN); if (ctx->progress_func) { ctx->progress_func( WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN, @@ -1858,16 +1858,12 @@ dentry_calculate_extraction_name(struct wim_dentry *dentry, } if (file_name_valid(dentry->file_name, dentry->file_name_nbytes / 2, false)) { -#if TCHAR_IS_UTF16LE - dentry->extraction_name = dentry->file_name; - dentry->extraction_name_nchars = dentry->file_name_nbytes / 2; - return 0; -#else - return utf16le_to_tstr(dentry->file_name, + ret = utf16le_get_tstr(dentry->file_name, dentry->file_name_nbytes, - &dentry->extraction_name, + (const tchar **)&dentry->extraction_name, &dentry->extraction_name_nchars); -#endif + dentry->extraction_name_nchars /= sizeof(tchar); + return ret; } else { if (ctx->extract_flags & WIMLIB_EXTRACT_FLAG_REPLACE_INVALID_FILENAMES) { @@ -1891,18 +1887,17 @@ out_replace: memcpy(utf16_name_copy, dentry->file_name, dentry->file_name_nbytes); file_name_valid(utf16_name_copy, dentry->file_name_nbytes / 2, true); - tchar *tchar_name; + const tchar *tchar_name; size_t tchar_nchars; - #if TCHAR_IS_UTF16LE - tchar_name = utf16_name_copy; - tchar_nchars = dentry->file_name_nbytes / 2; - #else - ret = utf16le_to_tstr(utf16_name_copy, - dentry->file_name_nbytes, - &tchar_name, &tchar_nchars); + + ret = utf16le_get_tstr(utf16_name_copy, + dentry->file_name_nbytes, + &tchar_name, &tchar_nchars); if (ret) return ret; - #endif + + tchar_nchars /= sizeof(tchar); + size_t fixed_name_num_chars = tchar_nchars; tchar fixed_name[tchar_nchars + 50]; @@ -1910,9 +1905,9 @@ out_replace: fixed_name_num_chars += tsprintf(fixed_name + tchar_nchars, T(" (invalid filename #%lu)"), ++ctx->invalid_sequence); - #if !TCHAR_IS_UTF16LE - FREE(tchar_name); - #endif + + utf16le_put_tstr(tchar_name); + dentry->extraction_name = memdup(fixed_name, 2 * fixed_name_num_chars + 2); if (!dentry->extraction_name)