]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
We should only use FindFirstFile for the path provided on the command line if it...
authorTim Kientzle <kientzle@gmail.com>
Mon, 31 Aug 2009 03:45:49 +0000 (23:45 -0400)
committerTim Kientzle <kientzle@gmail.com>
Mon, 31 Aug 2009 03:45:49 +0000 (23:45 -0400)
SVN-Revision: 1406

tar/tree.c

index 6bfb702693636da261fa70acd18e4915293ad17f..abc3cfa65d35461e3cb3f1dfa178b566b74f0026 100644 (file)
@@ -386,28 +386,34 @@ tree_next(struct tree *t)
 #if defined(_WIN32) && !defined(__CYGWIN__)
                        char *d = strdup(t->stack->name);
                        char *p, *pattern;
-                       tree_pop(t);
-                       if ((p = strrchr(d, '\\')) != NULL) {
-                               pattern = strdup(p + 1);
-                               p[1] = '\0';
-                               chdir(d);
-                               tree_append(t, d, strlen(d));
-                       } else {
-                               abort();
+                       //tree_pop(t);
+                       t->stack->flags &= ~needsFirstVisit;
+                       if (strchr(d, '*') || strchr(d, '?')) {
+                               // It has a wildcard in it...
+                               if ((p = strrchr(d, '\\')) != NULL) {
+                                       pattern = strdup(p + 1);
+                                       p[1] = '\0';
+                                       chdir(d);
+                                       tree_append(t, d, strlen(d));
+                                       free(d);
+                               } else {
+                                       pattern = d;
+                               }
+                               r = tree_dir_next_windows(t, pattern);
+                               free(pattern);
+                               if (r == 0)
+                                       continue;
+                               return (r);
                        }
-                       r = tree_dir_next_windows(t, pattern);
-                       free(pattern);
-                       if (r == 0)
-                               continue;
-                       return (r);
-#else
+                       // Not a pattern, handle it as-is...
+#endif
                        /* Top stack item needs a regular visit. */
                        t->current = t->stack;
                        tree_append(t, t->stack->name, strlen(t->stack->name));
                        t->dirname_length = t->path_length;
-                       tree_pop(t);
+                       //tree_pop(t);
+                       t->stack->flags &= ~needsFirstVisit;
                        return (t->visit_type = TREE_REGULAR);
-#endif
                } else if (t->stack->flags & needsDescent) {
                        /* Top stack item is dir to descend into. */
                        t->current = t->stack;