package tar-unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Unix I/O for tar-formatted data.

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

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 | error ]) result

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 ]) result

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 ]) result

header_of_file ~level filename returns the tar header of filename.

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

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 -> Unix.file_descr -> (unit, [ `Msg of string | `Unix of Unix.error * string * string ]) result

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

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

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

val write_end : Unix.file_descr -> (unit, [> `Msg of string ]) result

write_end fd writes the tar end marker to fd.

OCaml

Innovation. Community. Security.