Tar
Tar utilities
v3.1.2 - homepage
The type of errors that may occur.
val pp_error : Stdlib.Format.formatter -> [< error ] -> unit
pp_error ppf e
pretty prints the error e
on the formatter ppf
.
module Header : sig ... end
Process and create tar file headers.
val decode_state : ?global:Header.Extended.t -> unit -> decode_state
decode_state ~global ()
constructs a decode_state.
val decode :
decode_state ->
string ->
(decode_state
* [ `Read of int | `Skip of int | `Header of Header.t ] option
* Header.Extended.t option,
[ `Eof | `Fatal of error ])
Stdlib.result
decode t data
decodes data
taking the current state t
into account. It may result on success in a new state, optionally some action that should be done (`Read
or `Skip
), or a decoded `Header
. Possibly a new global PAX header is provided as well.
If no `Read
or `Skip
is returned, the new state should be used with decode
with the next Header.length
sized string, which will lead to further decoding until `Eof
(or an error) occurs.
val encode_header :
?level:Header.compatibility ->
Header.t ->
(string list, [> `Msg of string ]) Stdlib.result
encode_header ~level hdr
encodes the header with the provided level
(defaults to V7
) into a list of strings to be written to the disk. Once a header is written, the payload (padded to multiples of Header.length
) should follow.
val encode_global_extended_header :
?level:Header.compatibility ->
Header.Extended.t ->
(string list, [> `Msg of string ]) Stdlib.result
encode_global_extended_header hdr
encodes the global extended header as a list of strings.
fold
.fold
produces a ('a, 'err, 't) t
value which can be evaluated by a scheduler (such as lwt
or unix
). This value describe when we require to Read
(like Stdlib.input
), Really_read
(like Stdlib.really_read
) and Seek
(like Stdlib.seek_in
).
We can compose these actions with Bind
, Return
and High
. The latter allows you to use a value ('a, 't) io
that comes from the scheduler used - so you can use an Lwt value ('a Lwt.t
) without depending on Lwt (('a, lwt) t
) at this stage.
For further informations, you can look at the paper about Lightweight Higher Kind Polymorphism available here.
type ('a, 'err, 't) t =
| Really_read : int -> (string, 'err, 't) t
| Read : int -> (string, 'err, 't) t
| Seek : int -> (unit, 'err, 't) t
| Bind : ('a, 'err, 't) t * ('a -> ('b, 'err, 't) t) -> ('b, 'err, 't) t
| Return : ('a, 'err) Stdlib.result -> ('a, 'err, 't) t
| High : (('a, 'err) Stdlib.result, 't) io -> ('a, 'err, 't) t
| Write : string -> (unit, 'err, 't) t
val really_read : int -> (string, _, _) t
val read : int -> (string, _, _) t
val seek : int -> (unit, _, _) t
val return : ('a, 'err) Stdlib.result -> ('a, 'err, _) t
val write : string -> (unit, _, _) t
type ('a, 'err, 't) fold =
(?global:Header.Extended.t -> Header.t -> 'a -> ('a, 'err, 't) t) ->
'a ->
('a, 'err, 't) t
fold f
is a _ t
that reads an archive and executes f
on each header. f
is expected to either read or skip the file contents, or return an error.
type ('err, 't) content = unit -> (string option, 'err, 't) t
type ('err, 't) entry =
Header.compatibility option * Header.t * ('err, 't) content
val out :
?level:Header.compatibility ->
?global_hdr:Header.Extended.t ->
([> `Msg of string ] as 'err, 't) entries ->
(unit, 'err, 't) t
out hdr entries
is a _ t
that writes entries
into an archive. hdr
is the global header and each entry must come from a content
stream and the associated header.