X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fwin32_apply.c;h=56f82b6bfab953922d7c8b8eb39ba8b7f66d9e28;hb=290ada296b4be9bb48687a8e2bf6222b5c2daad7;hp=48ff5d87e01efa609745090195cd0903546a75ca;hpb=ad8c3f70361e25b7c1bbc46d4429749c7215fa12;p=wimlib diff --git a/src/win32_apply.c b/src/win32_apply.c index 48ff5d87..56f82b6b 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -30,14 +30,14 @@ #include "wimlib/win32_common.h" #include "wimlib/apply.h" -#include "wimlib/capture.h" +#include "wimlib/capture.h" /* for mangle_pat() */ #include "wimlib/dentry.h" #include "wimlib/error.h" #include "wimlib/lookup_table.h" -#include "wimlib/paths.h" #include "wimlib/resource.h" #include "wimlib/textfile.h" #include "wimlib/xml.h" +#include "wimlib/wildcard.h" #include "wimlib/wim.h" #include "wimlib/wimboot.h" @@ -114,6 +114,7 @@ load_prepopulate_pats(struct apply_ctx *ctx) LOAD_TEXT_FILE_REMOVE_QUOTES | LOAD_TEXT_FILE_NO_WARNINGS, mangle_pat); + BUILD_BUG_ON(OS_PREFERRED_PATH_SEPARATOR != WIM_PATH_SEPARATOR); FREE(buf); if (ret) { FREE(s); @@ -129,15 +130,24 @@ in_prepopulate_list(struct wim_dentry *dentry, struct apply_ctx *ctx) { struct string_set *pats; const tchar *path; + size_t path_nchars; pats = get_private_data(ctx)->prepopulate_pats; - if (!pats) + if (!pats || !pats->num_strings) return false; + path = dentry_full_path(dentry); if (!path) return false; - return match_pattern(path, path_basename(path), pats); + path_nchars = tstrlen(path); + + for (size_t i = 0; i < pats->num_strings; i++) + if (match_path(path, path_nchars, pats->strings[i], + OS_PREFERRED_PATH_SEPARATOR, true)) + return true; + + return false; } static int @@ -392,23 +402,48 @@ win32_extract_stream(const wchar_t *path, const wchar_t *stream_name, creationDisposition, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL); - if (h == INVALID_HANDLE_VALUE) - goto error; + if (h == INVALID_HANDLE_VALUE) { + set_errno_from_GetLastError(); + ret = WIMLIB_ERR_OPEN; + goto out; + } - ret = 0; - if (!lte) + if (!lte) { + ret = 0; goto out_close_handle; + } + + if (!SetFilePointerEx(h, + (LARGE_INTEGER) { .QuadPart = lte->size}, + NULL, + FILE_BEGIN)) + goto write_error; + + if (!SetEndOfFile(h)) + goto write_error; + + if (!SetFilePointerEx(h, + (LARGE_INTEGER) { .QuadPart = 0}, + NULL, + FILE_BEGIN)) + goto write_error; + ret = extract_stream(lte, lte->size, win32_extract_wim_chunk, h); -out_close_handle: - if (!CloseHandle(h)) - goto error; - if (ret && !errno) - errno = -1; - return ret; + goto out_close_handle; -error: +write_error: set_errno_from_GetLastError(); - return WIMLIB_ERR_WRITE; + ret = WIMLIB_ERR_WRITE; + +out_close_handle: + if (!CloseHandle(h)) { + if (!ret) { + set_errno_from_GetLastError(); + ret = WIMLIB_ERR_WRITE; + } + } +out: + return ret; } static int @@ -421,16 +456,27 @@ win32_extract_unnamed_stream(file_spec_t file, && lte && lte->resource_location == RESOURCE_IN_WIM && lte->rspec->wim == ctx->wim - && lte->size == lte->rspec->uncompressed_size - && !in_prepopulate_list(dentry, ctx)) + && lte->size == lte->rspec->uncompressed_size) { - const struct win32_apply_private_data *dat; + if (in_prepopulate_list(dentry, ctx)) { + if (ctx->progress_func) { + union wimlib_progress_info info; - dat = get_private_data(ctx); - return wimboot_set_pointer(file.path, lte, - dat->data_source_id, - dat->wim_lookup_table_hash, - dat->wof_running); + info.wimboot_exclude.path_in_wim = dentry->_full_path; + info.wimboot_exclude.extraction_path = file.path; + + ctx->progress_func(WIMLIB_PROGRESS_MSG_WIMBOOT_EXCLUDE, + &info); + } + } else { + const struct win32_apply_private_data *dat; + + dat = get_private_data(ctx); + return wimboot_set_pointer(file.path, lte, + dat->data_source_id, + dat->wim_lookup_table_hash, + dat->wof_running); + } } return win32_extract_stream(file.path, NULL, 0, lte, ctx);