Uses pathcmp() where appropriate instead of fnmatch().

This commit is contained in:
Andrea Mazzoleni 2013-06-01 22:49:15 +02:00
parent 2cc948a50c
commit a84bd62ee6
3 changed files with 7 additions and 6 deletions

7
elem.c
View file

@ -260,15 +260,12 @@ int filter_content(tommy_list* contentlist, const char* path)
struct snapraid_content* content = i->data;
char tmp[PATH_MAX];
/* FNM_PATHNAME because we are comparing full path */
/* FNM_NOESCAPE because the pattern is also a path, surely without escape chars */
/* FNM_CASEINSENSITIVE_FOR_WIN ignore case only in windows */
if (fnmatch(content->content, path, FNM_PATHNAME | FNM_NOESCAPE | FNM_CASEINSENSITIVE_FOR_WIN) == 0)
if (pathcmp(content->content, path) == 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 | FNM_CASEINSENSITIVE_FOR_WIN) == 0)
if (pathcmp(tmp, path) == 0)
return -1;
}

4
util.c
View file

@ -660,8 +660,12 @@ int pathcmp(const char* a, const char* b)
#ifdef _WIN32
char ai[PATH_MAX];
char bi[PATH_MAX];
/* import to convert \ to / */
pathimport(ai, sizeof(ai), a);
pathimport(bi, sizeof(bi), b);
/* case insensitive compare in Windows */
return stricmp(ai, bi);
#else
return strcmp(a, b);

2
util.h
View file

@ -336,7 +336,7 @@ void pathslash(char* dst, size_t size);
/**
* Compare two paths.
* In Windows it's case insentive.
* In Windows it's case insentive and assumes \ equal at /.
*/
int pathcmp(const char* a, const char* b);