Returns the next header block or fails with
Tar.Header.End_of_stream if two consecutive zero-filled blocks are discovered. Assumes stream is positioned at the possible start of a header block.
really_read fd buf fills
buf with data from
fd or raises
val write_block : ?level:Tar.Header.compatibility -> Tar.Header.t -> out_channel -> (unit -> string option Async.t) -> unit Async.t
write_block hdr oc stream writes
hdr, then deflate the given
stream, then zero-pads so the stream is positionned for the next block.
A simple usage to write a file:
let stream_of_fd fd = let buf = Bytes.create 0x1000 in fun () -> match Unix.read fd buf 0 (Bytes.length buf) with | 0 -> None | len -> Some (Bytes.sub_string buf 0 len) | exception End_of_file -> None let add_file oc filename = let fd = Unix.openfile filename Unix.[ O_RDONLY ] 0o644 in let hdr = Tar.Header.make ... in write_block hdr oc (stream_of_fd fd) ; Unix.close fd