]> wimlib.net Git - wimlib/commitdiff
Exclusion paths updates
authorEric Biggers <ebiggers3@gmail.com>
Mon, 27 Aug 2012 03:52:18 +0000 (22:52 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 27 Aug 2012 03:52:18 +0000 (22:52 -0500)
- Strip drive letter if given.
- Allow paths relative to capture root to begin with a non-slash character,
  provided that they contain another slash somewhere in them (otherwise they are
  interpreted as a filename pattern).

src/modify.c

index 799f6150a6bb25522a31abab44d6e89e98402aeb..d7f4f69bbc9c308f672286621ce3b3b75294c9a1 100644 (file)
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <errno.h>
 #include <fnmatch.h>
+#include <ctype.h>
 #include <unistd.h>
 
 /** Private flag: Used to mark that we currently adding the root directory of
@@ -617,6 +618,10 @@ static int init_capture_config(const char *_config_str, size_t config_len,
                        if (*pp == '\\')
                                *pp = '/';
 
+               /* Remove drive letter */
+               if (eol - p > 2 && isalpha(*p) && *(p + 1) == ':')
+                       p += 2;
+
                if (strcmp(p, "[ExclusionList]") == 0)
                        type = EXCLUSION_LIST;
                else if (strcmp(p, "[ExclusionException]") == 0)
@@ -665,9 +670,16 @@ static bool match_pattern(const char *path, const char *path_basename,
                const char *pat = list->pats[i];
                const char *string;
                if (pat[0] == '/')
+                       /* Absolute path from root of capture */
                        string = path;
-               else
-                       string = path_basename;
+               else {
+                       if (strchr(pat, '/'))
+                               /* Relative path from root of capture */
+                               string = path + 1;
+                       else
+                               /* A file name pattern */
+                               string = path_basename;
+               }
                if (fnmatch(pat, string, FNM_PATHNAME) == 0) {
                        DEBUG("`%s' matches the pattern \"%s\"",
                              string, pat);