]> git.ipfire.org Git - pakfire.git/commitdiff
files: Strip leading "./" from filenames
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 09:44:50 +0000 (09:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 09:44:50 +0000 (09:44 +0000)
mtree adds ./ to every file that is being written to the archive, but
that is not very useful for us.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/file.c

index cf7f38b97cb28b19bcae6c70b057b977fe441f64..c0d539f47b58b89457fe4b51f4de8b2e93105144 100644 (file)
@@ -153,7 +153,14 @@ int pakfire_file_copy_archive_entry(struct pakfire_file* file, struct archive_en
        pakfire_file_set_abspath(file, archive_entry_sourcepath(entry));
 
        // Set path
-       pakfire_file_set_path(file, archive_entry_pathname(entry));
+       const char* path = archive_entry_pathname(entry);
+       if (path) {
+               // Strip any leading dots from paths
+               if (pakfire_string_startswith(path, "./"))
+                       path++;
+
+               pakfire_file_set_path(file, path);
+       }
 
        // Set size
        pakfire_file_set_size(file, archive_entry_size(entry));