Add wildcard support to excludes.

This commit is contained in:
Vreixo Formoso
2008-01-30 21:40:26 +01:00
parent 04078d12ef
commit b6362a8680
3 changed files with 56 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include <time.h>
#include <limits.h>
#include <stdio.h>
#include <fnmatch.h>
/**
* Add a new directory to the iso tree.
@ -479,9 +480,24 @@ static
int check_excludes(IsoImage *image, const char *path)
{
int i;
for (i = 0; i < image->nexcludes; ++i) {
if (strcmp(image->excludes[i], path) == 0) {
return 1;
char *exclude = image->excludes[i];
if (exclude[0] == '/') {
/* absolute exclude, must completely match path */
if (!fnmatch(exclude, path, FNM_PERIOD|FNM_FILE_NAME)) {
return 1;
}
} else {
/* relative exclude, it is enought if a part of the path matches */
char *pos = (char*)path;
while (pos != NULL) {
pos++;
if (!fnmatch(exclude, pos, FNM_PERIOD|FNM_FILE_NAME)) {
return 1;
}
pos = strchr(pos, '/');
}
}
}
return 0;