]> git.ipfire.org Git - pakfire.git/commitdiff
filelist: Include all files in a directory
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Jun 2021 14:12:23 +0000 (14:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 3 Jun 2021 14:12:23 +0000 (14:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/filelist.c

index 09d03fbaf622b749af4b191a1a61991cde02f8a3..4e6425d08ff2e0ccf8036918eeb306ce9638d5a4 100644 (file)
@@ -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