Module Tar_lwt_unix

Lwt_unix I/O for tar-formatted data

type decode_error = [
  1. | `Fatal of Tar.error
  2. | `Unix of Unix.error * string * string
  3. | `Unexpected_end_of_file
  4. | `Msg of string
]
val pp_decode_error : Stdlib.Format.formatter -> decode_error -> unit
type t
val run : ('a, [> decode_error ] as 'b, t) Tar.t -> Lwt_unix.file_descr -> ('a, 'b) Stdlib.result Lwt.t
val value : ('a, 'err) Stdlib.result Lwt.t -> ('a, 'err, t) Tar.t
val fold : (?global:Tar.Header.Extended.t -> Tar.Header.t -> 'a -> ('a, [> decode_error ] as 'err, t) Tar.t) -> string -> 'a -> ('a, 'err) Stdlib.result Lwt.t

fold f filename acc folds over the tar archive. The function f is called for each hdr : Tar.Header.t. It should forward the position in the file descriptor by hdr.Tar.Header.file_size.

val extract : ?filter:(Tar.Header.t -> bool) -> src:string -> string -> (unit, [> `Exn of exn | decode_error ]) Stdlib.result Lwt.t

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 create : ?level:Tar.Header.compatibility -> ?global:Tar.Header.Extended.t -> ?filter:(Tar.Header.t -> bool) -> src:string -> string -> (unit, [ `Msg of string | `Unix of Unix.error * string * string ]) Stdlib.result Lwt.t

create ~level ~filter ~src dst creates a tar archive at dst. It uses src, a directory name, as input. If filter is provided (defaults to fun _ -> true), any file where filter hdr returns false is skipped.

val header_of_file : ?level:Tar.Header.compatibility -> string -> (Tar.Header.t, [ `Msg of string | `Unix of Unix.error * string * string ]) Stdlib.result Lwt.t

header_of_file ~level filename returns the tar header of filename.

val append_file : ?level:Tar.Header.compatibility -> ?header:Tar.Header.t -> string -> Lwt_unix.file_descr -> (unit, [ `Msg of string | `Unix of Unix.error * string * string ]) Stdlib.result Lwt.t

append_file ~level ~header filename fd appends the contents of filename to the tar archive fd. If header is not provided, header_of_file is used for constructing a header.

val write_header : ?level:Tar.Header.compatibility -> Tar.Header.t -> Lwt_unix.file_descr -> (unit, [ `Msg of string | `Unix of Unix.error * string * string ]) Stdlib.result Lwt.t

write_header ~level hdr fd writes the header hdr to fd.

val write_global_extended_header : ?level:Tar.Header.compatibility -> Tar.Header.Extended.t -> Lwt_unix.file_descr -> (unit, [ `Msg of string | `Unix of Unix.error * string * string ]) Stdlib.result Lwt.t

write_global_extended_header ~level hdr fd writes the extended header hdr to fd.

val write_end : Lwt_unix.file_descr -> (unit, [ `Msg of string ]) Stdlib.result Lwt.t

write_end fd writes the tar end marker to fd.