diff --git a/elem.c b/elem.c index 672fa0f4..fdee727a 100644 --- a/elem.c +++ b/elem.c @@ -130,10 +130,10 @@ static int filter_apply(struct snapraid_filter* filter, const char* path, const if (filter->is_path) { /* skip initial slash, as always missing from the path */ - if (fnmatch(filter->pattern + 1, path, FNM_PATHNAME) == 0) + if (fnmatch(filter->pattern + 1, path, FNM_PATHNAME | FNM_CASEINSENSITIVE_FOR_WIN) == 0) return filter->direction; } else { - if (fnmatch(filter->pattern, name, 0) == 0) + if (fnmatch(filter->pattern, name, FNM_CASEINSENSITIVE_FOR_WIN) == 0) return filter->direction; } @@ -186,8 +186,7 @@ static int filter_element(tommy_list* filterlist, const char* disk, const char* struct snapraid_filter* filter = i->data; if (filter->is_disk) { - /* using fnmatch allows to ignore case in windows */ - if (fnmatch(filter->pattern, disk, 0) == 0) + if (fnmatch(filter->pattern, disk, FNM_CASEINSENSITIVE_FOR_WIN) == 0) ret = filter->direction; else ret = 0; @@ -263,13 +262,13 @@ int filter_content(tommy_list* contentlist, const char* path) /* FNM_PATHNAME because we are comparing full path */ /* FNM_NOESCAPE because the pattern is also a path, surely without escape chars */ - /* using fnmatch allows to ignore case in windows */ - if (fnmatch(content->content, path, FNM_PATHNAME | FNM_NOESCAPE) == 0) + /* FNM_NOCASEINWIN ignore case only in windows */ + if (fnmatch(content->content, path, FNM_PATHNAME | FNM_NOESCAPE | FNM_CASEINSENSITIVE_FOR_WIN) == 0) return -1; /* exclude also the ".tmp" copy used to save it */ pathprint(tmp, sizeof(tmp), "%s.tmp", content->content); - if (fnmatch(tmp, path, FNM_PATHNAME | FNM_NOESCAPE) == 0) + if (fnmatch(tmp, path, FNM_PATHNAME | FNM_NOESCAPE | FNM_CASEINSENSITIVE_FOR_WIN) == 0) return -1; } diff --git a/portable.h b/portable.h index 67ce7ef5..9ce0cafb 100644 --- a/portable.h +++ b/portable.h @@ -101,6 +101,15 @@ #include "fnmatch.h" #endif +/** + * Disable case check in Windows. + */ +#ifdef _WIN32 +#define FNM_CASEINSENSITIVE_FOR_WIN FNM_CASEFOLD +#else +#define FNM_CASEINSENSITIVE_FOR_WIN 0 +#endif + #if HAVE_IO_H #include #endif diff --git a/scan.c b/scan.c index d12b8118..41f67ce6 100644 --- a/scan.c +++ b/scan.c @@ -587,7 +587,7 @@ static int scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, in exit(EXIT_FAILURE); } - /* exclude hidden stuff even beforer calling lstat() */ + /* exclude hidden files even beforer calling lstat() */ if (filter_hidden(state->filter_hidden, dd) != 0) { if (state->verbose) { printf("Excluding hidden '%s'\n", path_next); @@ -595,7 +595,7 @@ static int scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, in continue; } - /* exclude content files even beforer calling lstat() */ + /* exclude content files even before calling lstat() */ if (filter_content(&state->contentlist, path_next) != 0) { if (state->verbose) { printf("Excluding content '%s'\n", path_next);