]> wimlib.net Git - wimlib/blobdiff - src/capture_common.c
canonicalize_fs_path(): Retain backslashes
[wimlib] / src / capture_common.c
index 431a468116decb92d4aaef4b7167f1bc9a3c45b5..0a6ba44d2b98ea7f3c3a1be58e5b9ee889c97dc7 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ * capture_common.c - Mostly code to handle excluding paths from capture.
+ */
+
 /*
  * Copyright (C) 2013 Eric Biggers
  *
 /*
  * Copyright (C) 2013 Eric Biggers
  *
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include "wimlib_internal.h"
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 
-#include <string.h>
+#include "wimlib/assert.h"
+#include "wimlib/capture.h"
+#include "wimlib/error.h"
+#include "wimlib/paths.h"
 
 #ifdef __WIN32__
 
 #ifdef __WIN32__
-#  include "win32.h"
+#  include "wimlib/win32.h" /* for fnmatch() equivalent */
 #else
 #  include <fnmatch.h>
 #endif
 #else
 #  include <fnmatch.h>
 #endif
+#include <string.h>
+
 
 static int
 canonicalize_pattern(const tchar *pat, tchar **canonical_pat_ret)
 
 static int
 canonicalize_pattern(const tchar *pat, tchar **canonical_pat_ret)
@@ -56,6 +67,7 @@ canonicalize_pattern(const tchar *pat, tchar **canonical_pat_ret)
        canonical_pat = canonicalize_fs_path(pat);
        if (!canonical_pat)
                return WIMLIB_ERR_NOMEM;
        canonical_pat = canonicalize_fs_path(pat);
        if (!canonical_pat)
                return WIMLIB_ERR_NOMEM;
+       zap_backslashes(canonical_pat);
        *canonical_pat_ret = canonical_pat;
        return 0;
 }
        *canonical_pat_ret = canonical_pat;
        return 0;
 }
@@ -178,6 +190,8 @@ bool
 exclude_path(const tchar *path, size_t path_len,
             const struct wimlib_capture_config *config, bool exclude_prefix)
 {
 exclude_path(const tchar *path, size_t path_len,
             const struct wimlib_capture_config *config, bool exclude_prefix)
 {
+       if (!config)
+               return false;
        const tchar *basename = path_basename_with_len(path, path_len);
        if (exclude_prefix) {
                wimlib_assert(path_len >= config->_prefix_num_tchars);
        const tchar *basename = path_basename_with_len(path, path_len);
        if (exclude_prefix) {
                wimlib_assert(path_len >= config->_prefix_num_tchars);