]> wimlib.net Git - wimlib/blobdiff - src/wildcard.c
Update progress functions
[wimlib] / src / wildcard.c
index 742b564782d3219156ec5f669d2f6432d0bf1e8b..408b0fe32e73b1cd3df618c9be8b950a174633d7 100644 (file)
@@ -106,16 +106,17 @@ match_wildcard(const tchar *string, const tchar *wildcard,
  *     path separators in the pattern must be @path_sep, and there cannot be
  *     consecutive path separators, and there cannot be a trailing path
  *     separator.  If there is a leading path separator, the match is attempted
- *     with the filename only; otherwise, the matchis attempted with the whole
+ *     with the filename only; otherwise, the match is attempted with the whole
  *     path.
  *
  * @path_sep
- *     Path separator character in @path and @wildcard.
+ *     Path separator character used in @path and @wildcard.
  *
  * @prefix_ok
  *     If %true, allow a prefix of @path, terminated by a path separator, to
- *     match, in addition to @path itself.  a.k.a. also return true if the
- *     wildcard actually matches one of the ancestor directories of @path.
+ *     match the pattern, in addition to @path itself.  In other words, return
+ *     %true if the pattern actually matches one of the ancestor directories of
+ *     @path.
  *
  * Returns %true if there was a match; %false if there was not.
  */
@@ -187,29 +188,25 @@ wildcard_status(const tchar *wildcard)
 static int
 match_dentry(struct wim_dentry *cur_dentry, struct match_dentry_ctx *ctx)
 {
-       tchar *name;
-       size_t name_len;
+       const tchar *name;
+       size_t name_nchars;
        int ret;
 
        if (cur_dentry->file_name_nbytes == 0)
                return 0;
 
-#if TCHAR_IS_UTF16LE
-       name = cur_dentry->file_name;
-       name_len = cur_dentry->file_name_nbytes;
-#else
-       ret = utf16le_to_tstr(cur_dentry->file_name,
-                             cur_dentry->file_name_nbytes,
-                             &name, &name_len);
+       ret = utf16le_get_tstr(cur_dentry->file_name,
+                              cur_dentry->file_name_nbytes,
+                              &name, &name_nchars);
        if (ret)
                return ret;
-#endif
-       name_len /= sizeof(tchar);
+       name_nchars /= sizeof(tchar);
 
-       if (match_wildcard(name,
-                          &ctx->wildcard_path[ctx->cur_component_offset],
-                          ctx->cur_component_len,
-                          ctx->case_insensitive))
+       if (do_match_wildcard(name,
+                             name_nchars,
+                             &ctx->wildcard_path[ctx->cur_component_offset],
+                             ctx->cur_component_len,
+                             ctx->case_insensitive))
        {
                switch (wildcard_status(&ctx->wildcard_path[
                                ctx->cur_component_offset +
@@ -234,9 +231,8 @@ match_dentry(struct wim_dentry *cur_dentry, struct match_dentry_ctx *ctx)
                ret = 0;
        }
 
-#if !TCHAR_IS_UTF16LE
-       FREE(name);
-#endif
+       utf16le_put_tstr(name);
+
        return ret;
 }
 
@@ -331,7 +327,7 @@ expand_wildcard(WIMStruct *wim,
        struct wim_dentry *root;
        int ret;
 
-       root = wim_root_dentry(wim);
+       root = wim_get_current_root_dentry(wim);
        if (root == NULL)
                goto no_match;