mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Uses case insensitive comparison in Windows.
This commit is contained in:
parent
3949e32add
commit
52bc209e83
3 changed files with 17 additions and 9 deletions
13
elem.c
13
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <io.h>
|
||||
#endif
|
||||
|
|
|
|||
4
scan.c
4
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue