From: Michael Tremer Date: Thu, 3 Jun 2021 14:12:23 +0000 (+0000) Subject: filelist: Include all files in a directory X-Git-Tag: 0.9.28~1285^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f04561387201d1d6f9a6a54ac8fec9ae1843891c;p=pakfire.git filelist: Include all files in a directory Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index 09d03fbaf..4e6425d08 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -302,6 +302,17 @@ ERROR: return 1; } +// Returns true if s contains globbing characters +static int is_glob(const char* s) { + if (strchr(s, '*')) + return 1; + + if (strchr(s, '?')) + return 1; + + return 0; +} + static int pakfire_filelist_is_included(const char* path, const char** includes) { // If the includes list is empty, everything is included if (!includes) @@ -314,6 +325,14 @@ static int pakfire_filelist_is_included(const char* path, const char** includes) if (strcmp(*include, "/") == 0) return 1; + // Match any subdirectories + if (pakfire_string_startswith(path, *include)) + return 1; + + // Skip fnmatch if the pattern doesn't have any globbing characters + if (!is_glob(*include)) + continue; + r = fnmatch(*include, path, 0); // Found a match