From dddcf401ad7a3a2c93412090dc791ffec39fa20f Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Sat, 3 Feb 2024 16:59:24 +0100 Subject: [PATCH] add filter --- unix/tar_unix.mli | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/unix/tar_unix.mli b/unix/tar_unix.mli index a6f61b5..cbea997 100644 --- a/unix/tar_unix.mli +++ b/unix/tar_unix.mli @@ -28,15 +28,23 @@ val fold : ]) result -> 'a -> 'a) -> string -> 'a -> 'a -(** [extract ~src ~dst] extracts the tar archive [src] into the directory [dst]. - If [dst] does not exist, it is created. *) -val extract : src:string -> dst:string -> +(** [extract ~filter ~src ~dst] extracts the tar archive [src] into the + directory [dst]. If [dst] does not exist, it is created. If [filter] is + provided (defaults to [fun _ -> true]), any file where [filter hdr] returns + [false], is skipped. *) +val extract : + ?filter:(Tar.Header.t -> bool) -> + src:string -> dst:string -> (unit, [ `Fatal of [ `Checksum_mismatch | `Corrupt_pax_header | `Unmarshal of string ] | `Unix of Unix.error ]) result -(** [create ~level ~src ~dst] creates a tar archive at [dst]. It uses [src], a - filename or directory name, as input. *) -val create : ?level:Tar.Header.compatibility -> src:string -> dst:string -> +(** [create ~level ~filter ~src ~dst] creates a tar archive at [dst]. It uses + [src], a filename or directory name, as input. If [filter] is provided + (defaults to [fun _ -> true]), any file where [filter hdr] returns [false] + is skipped. *) +val create : ?level:Tar.Header.compatibility -> + ?filter:(Tar.Header.t -> bool) -> + src:string -> dst:string -> (unit, [ `Msg of string | `Unix of Unix.error ]) result (** [header_of_file ~level filename] returns the tar header of [filename]. *)