Skip to content

Commit

Permalink
Harmonize Tar_unix and Tar_lwt_unix
Browse files Browse the repository at this point in the history
  • Loading branch information
reynir committed Jun 29, 2023
1 parent a821a2a commit 5eb8204
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
10 changes: 2 additions & 8 deletions unix/tar_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ module Io = struct
end

include Io
module HR = Tar.HeaderReader(Lwt)(Io)
module HW = Tar.HeaderWriter(Lwt)(Io)

let get_next_header ~global ic =
HR.read ~global ic
>>= function
| Error `Eof -> Lwt.return None
| Ok hdrs -> Lwt.return (Some hdrs)
module HeaderReader = Tar.HeaderReader(Lwt)(Io)
module HeaderWriter = Tar.HeaderWriter(Lwt)(Io)

(** Return the header needed for a particular file on disk *)
let header_of_file ?level (file: string) : Tar.Header.t Lwt.t =
Expand Down
12 changes: 6 additions & 6 deletions unix/tar_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ val really_write: Lwt_unix.file_descr -> Cstruct.t -> unit Lwt.t
(** [really_write fd buf] writes the full contents of [buf] to
[fd] or fails with {!Stdlib.End_of_file}. *)

(** Returns the next header block or None if two consecutive
zero-filled blocks are discovered. Assumes stream is positioned at the
possible start of a header block.
@raise Stdlib.End_of_file if the stream unexpectedly fails. *)
val get_next_header : global:Tar.Header.Extended.t option -> Lwt_unix.file_descr ->
(Tar.Header.t * Tar.Header.Extended.t option) option Lwt.t
val skip : Lwt_unix.file_descr -> int -> unit Lwt.t
(** [skip fd n] reads [n] bytes from [fd] and discards them. If possible, you
should use [Lwt_unix.lseek fd n Lwt_unix.SEEK_CUR] instead. *)

(** Return the header needed for a particular file on disk. *)
val header_of_file : ?level:Tar.Header.compatibility -> string -> Tar.Header.t Lwt.t

module HeaderReader : Tar.HEADERREADER with type in_channel = Lwt_unix.file_descr and type 'a io = 'a Lwt.t
module HeaderWriter : Tar.HEADERWRITER with type out_channel = Lwt_unix.file_descr and type 'a io = 'a Lwt.t
2 changes: 2 additions & 0 deletions unix/tar_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ val really_write: Unix.file_descr -> Cstruct.t -> unit
or {!Stdlib.End_of_file}. *)

val skip : Unix.file_descr -> int -> unit
(** [skip fd n] reads [n] bytes from [fd] and discards them. If possible, you
should use [Unix.lseek fd n Unix.SEEK_CUR] instead. *)

(** Return the header needed for a particular file on disk. *)
val header_of_file : ?level:Tar.Header.compatibility -> string -> Tar.Header.t
Expand Down

0 comments on commit 5eb8204

Please sign in to comment.