tar is a simple library to read and write tar files with an emphasis on streaming.
This is pure OCaml code, no C bindings.
tar
can be installed with opam
:
opam install tar
opam install tar-unix # for use in Unix/Lwt
opam install tar-mirage # for use in MirageOS
If you don't use opam
consult the tar.opam
file for build
instructions.
In utop:
utop # #require "tar";;
utop # #require "tar-unix";;
utop # let f = Lwt_unix.openfile "/tmp/foo.tar" [ Unix.O_RDONLY ] 0;;
val f : Lwt_unix.file_descr = <abstr>
utop # Lwt.bind f Tar_lwt_unix.Archive.list;;
[{Tar.Header.file_name = "_build/lib/tar.mli.depends";
Tar.Header.file_mode = 420; Tar.Header.user_id = 1000;
Tar.Header.group_id = 1000; Tar.Header.file_size = 21L;
Tar.Header.mod_time = 1381080315L;
Tar.Header.link_indicator = Tar.Header.Link.Normal;
Tar.Header.link_name = ""};
{Tar.Header.file_name = "_build/lib/tar_unix.mli.depends";
Tar.Header.file_mode = 420; Tar.Header.user_id = 1000;
Tar.Header.group_id = 1000; Tar.Header.file_size = 27L;
Tar.Header.mod_time = 1381080318L;
Tar.Header.link_indicator = Tar.Header.Link.Normal;
Tar.Header.link_name = ""};
{Tar.Header.file_name = "_build/lib/tar.mllib";
Tar.Header.file_mode = ...; Tar.Header.user_id = ...;
Tar.Header.group_id = ...; Tar.Header.file_size = ...;
Tar.Header.mod_time = ...; Tar.Header.link_indicator = ...;
Tar.Header.link_name = ...};
...]
This library is used by
- xapi to read and write VM images
The documentation and API reference is automatically generated by
ocamldoc
from the interfaces. It can be consulted online.