From f04561387201d1d6f9a6a54ac8fec9ae1843891c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 3 Jun 2021 14:12:23 +0000 Subject: [PATCH] filelist: Include all files in a directory Signed-off-by: Michael Tremer --- src/libpakfire/filelist.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 -- 2.47.2