]> wimlib.net Git - wimlib/blobdiff - src/modify.c
NTFS capture updates
[wimlib] / src / modify.c
index 799f6150a6bb25522a31abab44d6e89e98402aeb..141f2dd8aac45cb0de271803cb2a6d71a4258f8e 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
@@ -517,7 +518,7 @@ static const char *default_config =
 "\\$ntfs.log\n"
 "\\hiberfil.sys\n"
 "\\pagefile.sys\n"
-"\"\\System Volume Information\"\n"
+"\\System Volume Information\n"
 "\\RECYCLER\n"
 "\\Windows\\CSC\n"
 "\n"
@@ -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,10 +670,22 @@ 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;
-               if (fnmatch(pat, string, FNM_PATHNAME) == 0) {
+               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
+                       #ifdef FNM_CASEFOLD
+                                       | FNM_CASEFOLD
+                       #endif
+                       ) == 0)
+               {
                        DEBUG("`%s' matches the pattern \"%s\"",
                              string, pat);
                        return true;
@@ -710,7 +727,6 @@ bool exclude_path(const char *path, const struct capture_config *config,
 
 
 int do_add_image(WIMStruct *w, const char *dir, const char *name,
-                const char *description, const char *flags_element,
                 const char *config_str, size_t config_len,
                 int flags,
                 int (*capture_tree)(struct dentry **, const char *,
@@ -793,7 +809,7 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name,
        if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
                wimlib_set_boot_idx(w, w->hdr.image_count);
 
-       ret = xml_add_image(w, root_dentry, name, description, flags_element);
+       ret = xml_add_image(w, root_dentry, name);
        if (ret != 0)
                goto out_destroy_imd;
 
@@ -816,12 +832,9 @@ out_destroy_config:
  * Adds an image to a WIM file from a directory tree on disk.
  */
 WIMLIBAPI int wimlib_add_image(WIMStruct *w, const char *dir, 
-                              const char *name, const char *description, 
-                              const char *flags_element,
-                              const char *config_str,
+                              const char *name, const char *config_str,
                               size_t config_len, int flags)
 {
-       return do_add_image(w, dir, name, description, flags_element,
-                           config_str, config_len, flags,
+       return do_add_image(w, dir, name, config_str, config_len, flags,
                            build_dentry_tree, NULL);
 }