]> wimlib.net Git - wimlib/blobdiff - src/win32_apply.c
Simplify wildcard pattern expansion
[wimlib] / src / win32_apply.c
index 45b1d653ac78fdf715e7abfe452aa76bd6c06f80..289db30bca7f482ea2a699a31bbec531770a35d6 100644 (file)
 #include "wimlib/error.h"
 #include "wimlib/metadata.h"
 #include "wimlib/paths.h"
+#include "wimlib/pattern.h"
 #include "wimlib/reparse.h"
 #include "wimlib/textfile.h"
 #include "wimlib/xml.h"
-#include "wimlib/wildcard.h"
 #include "wimlib/wimboot.h"
 
 struct win32_apply_ctx {
@@ -122,12 +122,12 @@ struct win32_apply_ctx {
         * beginning of the array)  */
        unsigned num_open_handles;
 
-       /* List of dentries, joined by @tmp_list, that need to have reparse data
-        * extracted as soon as the whole blob has been read into @data_buffer.
-        * */
+       /* List of dentries, joined by @d_tmp_list, that need to have reparse
+        * data extracted as soon as the whole blob has been read into
+        * @data_buffer.  */
        struct list_head reparse_dentries;
 
-       /* List of dentries, joined by @tmp_list, that need to have raw
+       /* List of dentries, joined by @d_tmp_list, that need to have raw
         * encrypted data extracted as soon as the whole blob has been read into
         * @data_buffer.  */
        struct list_head encrypted_dentries;
@@ -341,28 +341,15 @@ load_prepopulate_pats(struct win32_apply_ctx *ctx)
        return 0;
 }
 
-/* Returns %true if the specified absolute path to a file in the WIM image
- * matches a pattern in [PrepopulateList] of WimBootCompress.ini.  Otherwise
- * returns %false.  */
-static bool
-in_prepopulate_list(const wchar_t *path, size_t path_nchars,
-                   const struct win32_apply_ctx *ctx)
-{
-       const struct string_set *pats = ctx->wimboot.prepopulate_pats;
-
-       if (!pats || !pats->num_strings)
-               return false;
-
-       return match_pattern_list(path, path_nchars, pats);
-}
-
 /* Returns %true if the specified absolute path to a file in the WIM image can
  * be subject to external backing when extracted.  Otherwise returns %false.  */
 static bool
-can_externally_back_path(const wchar_t *path, size_t path_nchars,
-                        const struct win32_apply_ctx *ctx)
+can_externally_back_path(const wchar_t *path, const struct win32_apply_ctx *ctx)
 {
-       if (in_prepopulate_list(path, path_nchars, ctx))
+       /* Does the path match a pattern given in the [PrepopulateList] section
+        * of WimBootCompress.ini?  */
+       if (ctx->wimboot.prepopulate_pats &&
+           match_pattern_list(path, ctx->wimboot.prepopulate_pats))
                return false;
 
        /* Since we attempt to modify the SYSTEM registry after it's extracted
@@ -374,8 +361,7 @@ can_externally_back_path(const wchar_t *path, size_t path_nchars,
         * However, a WIM that wasn't specifically captured in "WIMBoot mode"
         * may contain SYSTEM.* files.  So to make things "just work", hard-code
         * the pattern.  */
-       if (match_path(path, path_nchars, L"\\Windows\\System32\\config\\SYSTEM*",
-                      OS_PREFERRED_PATH_SEPARATOR, false))
+       if (match_path(path, L"\\Windows\\System32\\config\\SYSTEM*", false))
                return false;
 
        return true;
@@ -492,9 +478,7 @@ will_externally_back_inode(struct wim_inode *inode, struct win32_apply_ctx *ctx,
                if (ret)
                        return ret;
 
-               if (!can_externally_back_path(dentry->_full_path,
-                                             wcslen(dentry->_full_path), ctx))
-               {
+               if (!can_externally_back_path(dentry->d_full_path, ctx)) {
                        if (excluded_dentry_ret)
                                *excluded_dentry_ret = dentry;
                        return WIM_BACKING_EXCLUDED;
@@ -557,7 +541,7 @@ set_external_backing(HANDLE h, struct wim_inode *inode, struct win32_apply_ctx *
 
                build_extraction_path(excluded_dentry, ctx);
 
-               info.wimboot_exclude.path_in_wim = excluded_dentry->_full_path;
+               info.wimboot_exclude.path_in_wim = excluded_dentry->d_full_path;
                info.wimboot_exclude.extraction_path = current_path(ctx);
 
                return call_progress(ctx->common.progfunc,
@@ -1815,7 +1799,7 @@ begin_extract_blob_instance(const struct blob_descriptor *blob,
                 * data be available.  So, stage the data in a buffer.  */
                if (!prepare_data_buffer(ctx, blob->size))
                        return WIMLIB_ERR_NOMEM;
-               list_add_tail(&dentry->tmp_list, &ctx->reparse_dentries);
+               list_add_tail(&dentry->d_tmp_list, &ctx->reparse_dentries);
                return 0;
        }
 
@@ -1833,7 +1817,7 @@ begin_extract_blob_instance(const struct blob_descriptor *blob,
                 * such files...  */
                if (!prepare_data_buffer(ctx, blob->size))
                        return WIMLIB_ERR_NOMEM;
-               list_add_tail(&dentry->tmp_list, &ctx->encrypted_dentries);
+               list_add_tail(&dentry->d_tmp_list, &ctx->encrypted_dentries);
                return 0;
        }
 
@@ -2233,7 +2217,7 @@ end_extract_blob(struct blob_descriptor *blob, int status, void *_ctx)
        if (!list_empty(&ctx->reparse_dentries)) {
                if (blob->size > REPARSE_DATA_MAX_SIZE) {
                        dentry = list_first_entry(&ctx->reparse_dentries,
-                                                 struct wim_dentry, tmp_list);
+                                                 struct wim_dentry, d_tmp_list);
                        build_extraction_path(dentry, ctx);
                        ERROR("Reparse data of \"%ls\" has size "
                              "%"PRIu64" bytes (exceeds %u bytes)",
@@ -2245,7 +2229,7 @@ end_extract_blob(struct blob_descriptor *blob, int status, void *_ctx)
                /* Reparse data  */
                memcpy(ctx->rpbuf.rpdata, ctx->data_buffer, blob->size);
 
-               list_for_each_entry(dentry, &ctx->reparse_dentries, tmp_list) {
+               list_for_each_entry(dentry, &ctx->reparse_dentries, d_tmp_list) {
 
                        /* Reparse point header  */
                        complete_reparse_point(&ctx->rpbuf, dentry->d_inode,
@@ -2262,7 +2246,7 @@ end_extract_blob(struct blob_descriptor *blob, int status, void *_ctx)
 
        if (!list_empty(&ctx->encrypted_dentries)) {
                ctx->encrypted_size = blob->size;
-               list_for_each_entry(dentry, &ctx->encrypted_dentries, tmp_list) {
+               list_for_each_entry(dentry, &ctx->encrypted_dentries, d_tmp_list) {
                        ret = extract_encrypted_file(dentry, ctx);
                        ret = check_apply_error(dentry, ctx, ret);
                        if (ret)