package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0
doc/b0.std/B0_tar/index.html
Module B0_tar
Source
tar
file archives.
For making reproducible tar archives, an (us)tar archiver OCaml implementation is provided. Unarchiving and compression support occurs via shell outs.
References.
- ustar Interchange Format in POSIX 1003.1, 2013.
Ustar encoder
The type for POSIX times in seconds since the epoch.
The type for archive member.
The type for ustar archives.
add a path ~mode ~mtime member
adds member
to archive a
with file path path
, permission mode mode
and modificaton time mtime
.
val of_dir :
dir:B0_std.Fpath.t ->
exclude_paths:B0_std.Fpath.Set.t ->
root:B0_std.Fpath.t ->
mtime:int ->
(string, string) result
of_dir ~dir ~exclude_paths ~root ~mtime
is a (us)tar archive that contains the file hierarchy dir
except the relative hierarchies and files present in exclude_paths
. Symbolic links are followed.
In the archive, members of dir
are rerooted at root
and sorted according to B0_std.Fpath.compare
(for determinism). They have their modification time set to mtime
and their file permissions are 0o775
for directories and files executable by the user and 0o664
for other files. No other file metadata is preserved.
Compressing
val compress :
?search:B0_std.Cmd.tool_search ->
force:bool ->
make_path:bool ->
B0_std.Fpath.t ->
archive:string ->
(unit, string) result
compress ~force ~make_path file ~archive
compresses archive archive
to file
. For force
and make_path
see B0_std.Os.Cmd.out_file
.
The compression algorithm and tool looked up with search
(defaults to Os.Cmd.get ?search
) depends on the file extension of file
:
- For
.tar
no tool is used. - For
.tgz
or.gz
theCmd.tool "gzip"
tool is used. - For
.tbz
or.bzip2
theCmd.tool "bzip2"
tool is used. - For
.xz
then theCmd.tool "lzma"
tool is used. - For
.zst
then theCmt.tool "zstd"
tool is used. - Otherwise the function errors.
Unarchiving
val unarchive :
?search:B0_std.Cmd.tool_search ->
make_path:bool ->
verbose:bool ->
src:B0_std.Fpath.t ->
in_dir:B0_std.Fpath.t ->
unit ->
(unit, string) result
unarchive ~make_path ~src ~in_dir
unarchives src
in directory in_dir
which is created if it doesn't exist. For make_path
see B0_std.Os.Dir.create
. If verbose
is true
-v
is passed to tar
.
The compression algorithm and tool is to use is looked up with search
like in compress
.