]> wimlib.net Git - wimlib/blobdiff - src/wildcard.c
inode_fixup.c: Only warn when inconsistent inode detected
[wimlib] / src / wildcard.c
index c0f0adbdb6486b35b00227a43253b6c0402f9b95..7898690a5536f94d9830fdb2049a73070dcb667a 100644 (file)
@@ -129,7 +129,7 @@ wildcard_status(const tchar *wildcard)
 {
        if (*wildcard == T('\0'))
                return WILDCARD_STATUS_DONE_FULLY;
-       while (is_any_path_separator(*wildcard))
+       while (*wildcard == WIM_PATH_SEPARATOR)
                wildcard++;
        if (*wildcard == T('\0'))
                return WILDCARD_STATUS_DONE_TRAILING_SLASHES;
@@ -138,9 +138,8 @@ wildcard_status(const tchar *wildcard)
 }
 
 static int
-match_dentry(struct wim_dentry *cur_dentry, void *_ctx)
+match_dentry(struct wim_dentry *cur_dentry, struct match_dentry_ctx *ctx)
 {
-       struct match_dentry_ctx *ctx = _ctx;
        tchar *name;
        size_t name_len;
        int ret;
@@ -205,16 +204,17 @@ expand_wildcard_recursive(struct wim_dentry *cur_dentry,
        size_t offset_save;
        size_t len_save;
        int ret;
+       struct wim_dentry *child;
 
        w = ctx->wildcard_path;
 
        begin = ctx->cur_component_offset + ctx->cur_component_len;
-       while (is_any_path_separator(w[begin]))
+       while (w[begin] == WIM_PATH_SEPARATOR)
                begin++;
 
        end = begin;
 
-       while (w[end] != T('\0') && !is_any_path_separator(w[end]))
+       while (w[end] != T('\0') && w[end] != WIM_PATH_SEPARATOR)
                end++;
 
        len = end - begin;
@@ -228,7 +228,12 @@ expand_wildcard_recursive(struct wim_dentry *cur_dentry,
        ctx->cur_component_offset = begin;
        ctx->cur_component_len = len;
 
-       ret = for_dentry_child(cur_dentry, match_dentry, ctx);
+       ret = 0;
+       for_dentry_child(child, cur_dentry) {
+               ret = match_dentry(child, ctx);
+               if (ret)
+                       break;
+       }
 
        ctx->cur_component_len = len_save;
        ctx->cur_component_offset = offset_save;
@@ -243,9 +248,9 @@ expand_wildcard_recursive(struct wim_dentry *cur_dentry,
  *     wildcard.
  * @wildcard_path
  *     Wildcard path to expand, which may contain the '?' and '*' characters.
- *      Path separators may be either forward slashes, and leading path
- *      separators are ignored.  Trailing path separators indicate that the
- *      wildcard can only match directories.
+ *     Path separators must be WIM_PATH_SEPARATOR.  Leading path separators are
+ *     ignored, whereas one or more trailing path separators indicate that the
+ *     wildcard path can only match directories (and not reparse points).
  * @consume_dentry
  *     Callback function which will receive each directory entry matched by the
  *     wildcard.
@@ -268,9 +273,6 @@ expand_wildcard_recursive(struct wim_dentry *cur_dentry,
  *
  * @return 0 on success; a positive error code on error; or the first nonzero
  * value returned by @consume_dentry.
- *
- * Note: this function uses the @tmp_list field of dentries it attempts to
- * match.
  */
 int
 expand_wildcard(WIMStruct *wim,