package tar

  1. Overview
  2. Docs
Decode and encode tar format files in pure OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

tar-3.3.0.tbz
sha256=f3d6b0d677fd40fd1eb80bccc60bb613220358be58f66c5fa8bf0257f3e5eb96
sha512=be23a0337f1334b9ead1516745f1397afd240787bb983f037ea33434eea7f0c9dedf2e53ebd1b47a076220cac9d926370d1b8d2b329d1e16d02b9b0e517dd162

doc/tar/Tar/index.html

Module TarSource

Tar utilities

v3.3.0 - homepage

Sourcetype error = [
  1. | `Checksum_mismatch
  2. | `Corrupt_pax_header
  3. | `Zero_block
  4. | `Unmarshal of string
]

The type of errors that may occur.

Sourceval pp_error : Format.formatter -> [< error ] -> unit

pp_error ppf e pretty prints the error e on the formatter ppf.

Sourcemodule Header : sig ... end

Process and create tar file headers.

Decoding and encoding of a whole archive

Sourcetype decode_state

The type of the decode state.

Sourceval decode_state : ?global:Header.Extended.t -> unit -> decode_state

decode_state ~global () constructs a decode_state.

Sourceval 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 ]) 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.

Sourceval encode_header : ?level:Header.compatibility -> Header.t -> (string list, [> `Msg of string ]) 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.

Sourceval encode_global_extended_header : ?level:Header.compatibility -> Header.Extended.t -> (string list, [> `Msg of string ]) result

encode_global_extended_header hdr encodes the global extended header as a list of strings.

Pure implementation of 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.

Sourcetype ('a, 't) io
Sourcetype ('a, 'err, 't) t =
  1. | Really_read : int -> (string, 'err, 't) t
  2. | Read : int -> (string, 'err, 't) t
  3. | Seek : int -> (unit, 'err, 't) t
  4. | Bind : ('a, 'err, 't) t * ('a -> ('b, 'err, 't) t) -> ('b, 'err, 't) t
  5. | Return : ('a, 'err) result -> ('a, 'err, 't) t
  6. | High : (('a, 'err) result, 't) io -> ('a, 'err, 't) t
  7. | Write : string -> (unit, 'err, 't) t
Sourceval really_read : int -> (string, _, _) t
Sourceval read : int -> (string, _, _) t
Sourceval seek : int -> (unit, _, _) t
Sourceval bind : ('a, 'err, 't) t -> ('a -> ('b, 'err, 't) t) -> ('b, 'err, 't) t
Sourceval return : ('a, 'err) result -> ('a, 'err, _) t
Sourceval write : string -> (unit, _, _) t
Sourcemodule Syntax : sig ... end
Sourceval (let*) : ('a, 'err, 't) t -> ('a -> ('b, 'err, 't) t) -> ('b, 'err, 't) t

Deprecated. Use Tar.bind or Tar.Syntax.( let* )

  • deprecated Use Tar.bind or Tar.Syntax.( let* )
Sourcetype ('a, 'err, 't) fold = (?global:Header.Extended.t -> Header.t -> 'a -> ('a, 'err, 't) t) -> 'a -> ('a, 'err, 't) t
Sourceval fold : ('a, [> `Fatal of error ], 't) fold

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.

Sourcetype ('err, 't) content = unit -> (string option, 'err, 't) t
Sourcetype ('err, 't) entry = Header.compatibility option * Header.t * ('err, 't) content
Sourcetype ('err, 't) entries = unit -> (('err, 't) entry option, 'err, 't) t
Sourceval 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.

OCaml

Innovation. Community. Security.