Module Tar_eio

Eio Tar

This library provides low-level and high-level abstractions for reading and writing Tar files using Eio.

type t
type src =
  1. | Flow : _ Eio.Flow.source -> src
  2. | File : _ Eio.File.ro -> src
    (*

    Sources for tar files

    *)
type decode_error = [
  1. | `Fatal of Tar.error
  2. | `Unexpected_end_of_file
  3. | `Msg of string
]

Possible decoding errors

High-level Interface

val run : ('a, [> `Unexpected_end_of_file ] as 'b, t) Tar.t -> src -> ('a, 'b) Stdlib.result

run tar src will run the given tar using Eio on src.

val extract : ?filter:(Tar.Header.t -> bool) -> src -> Eio.Fs.dir_ty Eio.Path.t -> (unit, [> decode_error ]) Stdlib.result

extract src dst extracts the tar file from src into dst. For example:

Eio.Path.with_open_in src @@ fun src ->
Tar_eio.extract src dst

will extract the file at src into the directory at dst. Note that this function only creates files, directories and symlinks with the correct mode (it does not, for example, set the ownership of the files according to the tar file).

  • parameter filter

    Can be used to exclude certain entries based on their header.

val create : ?level:Tar.Header.compatibility -> ?global:Tar.Header.Extended.t -> ?filter:(Tar.Header.t -> bool) -> src:Eio.Fs.dir_ty Eio.Path.t -> _ Eio.Flow.sink -> (unit, [> decode_error ]) Stdlib.result

create ~src dst is the opposite of extract. The path src is tarred into dst.

  • parameter filter

    Can be used to exclude certain entries based on their header.

val fold : (?global:Tar.Header.Extended.t -> Tar.Header.t -> 'acc -> ('acc, [> `Fatal of Tar.error | `Unexpected_end_of_file ] as 'b, t) Tar.t) -> src -> 'acc -> ('acc, 'b) Stdlib.result

fold f src init folds over the tarred src.

Low-level Interface

val value : ('a, 'err) Stdlib.result -> ('a, 'err, t) Tar.t

Converts a normal result into Tars IO type

val append_file : ?level:Tar.Header.compatibility -> ?header:Tar.Header.t -> Eio.Fs.dir_ty Eio.Path.t -> _ Eio.Flow.sink -> (unit, [> decode_error ]) Stdlib.result

append_file dst sink

val header_of_file : ?level:Tar.Header.compatibility -> ?getpwuid:(int64 -> string) -> ?getgrgid:(int64 -> string) -> Eio.Fs.dir_ty Eio.Path.t -> Tar.Header.t

Return the header needed for a particular file on disk. getpwuid and getgrgid are optional functions that should take the uid and gid respectively and return the passwd and group entry names for each. These will be added to the header.

val write_header : ?level:Tar.Header.compatibility -> Tar.Header.t -> _ Eio.Flow.sink -> (unit, [> decode_error ]) Stdlib.result
val write_global_extended_header : ?level:Tar.Header.compatibility -> Tar.Header.Extended.t -> _ Eio.Flow.sink -> (unit, [> decode_error ]) Stdlib.result
val write_end : _ Eio.Flow.sink -> unit