From cf20a20560fc26fcba888baf6923bd21390c1f8c Mon Sep 17 00:00:00 2001 From: Robur Date: Wed, 3 Jan 2024 13:36:00 +0000 Subject: [PATCH] remove unused tar_cstruct module --- lib/dune | 2 +- lib/tar_cstruct.ml | 60 --------------------------------------------- lib/tar_cstruct.mli | 33 ------------------------- 3 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 lib/tar_cstruct.ml delete mode 100644 lib/tar_cstruct.mli diff --git a/lib/dune b/lib/dune index 17a6c55..1718831 100644 --- a/lib/dune +++ b/lib/dune @@ -1,6 +1,6 @@ (library (name tar) - (modules tar tar_cstruct) + (modules tar) (public_name tar) (wrapped false) (libraries cstruct)) diff --git a/lib/tar_cstruct.ml b/lib/tar_cstruct.ml deleted file mode 100644 index 186ffba..0000000 --- a/lib/tar_cstruct.ml +++ /dev/null @@ -1,60 +0,0 @@ -module Direct = struct - type 'a t = 'a - let return x = x - let ( >>= ) m f = f m -end - -module Cstruct_io = struct - (* Input from a single Cstruct.t value *) - - type 'a io = 'a Direct.t - - type in_channel = { - mutable pos : int; - data : Cstruct.t; - } - - let make_in_channel data = - { pos = 0; data } - - let check_available ch len = - min (Cstruct.length ch.data - ch.pos) len - - let read_zerocopy ic len = - if check_available ic len <> len then raise End_of_file; - let r = Cstruct.sub ic.data ic.pos len in - ic.pos <- ic.pos + len; - r - - let really_read ic buf = - let len = Cstruct.length buf in - if check_available ic len <> len then raise End_of_file; - Cstruct.blit ic.data ic.pos buf 0 len; - ic.pos <- ic.pos + len - - let skip ic n = - if check_available ic n <> n then raise End_of_file; - ic.pos <- ic.pos + n - - (* Output to a list of Cstruct.t values *) - - type out_channel = { - mutable data : Cstruct.t list; - } - - let make_out_channel () = { data = [] } - - let really_write oc buf = - oc.data <- Cstruct.sub_copy buf 0 (Cstruct.length buf) :: oc.data - - let to_string oc = - Cstruct.copyv (List.rev oc.data) - - let to_cstruct oc = - Cstruct.concat (List.rev oc.data) -end - -module HeaderReader = Tar.HeaderReader(Direct)(Cstruct_io) -module HeaderWriter = Tar.HeaderWriter(Direct)(Cstruct_io) - -include Cstruct_io diff --git a/lib/tar_cstruct.mli b/lib/tar_cstruct.mli deleted file mode 100644 index c93e5ed..0000000 --- a/lib/tar_cstruct.mli +++ /dev/null @@ -1,33 +0,0 @@ -(** {1 Processing tar content with cstruct buffers} *) - -type in_channel -type out_channel - -val make_in_channel : Cstruct.t -> in_channel -(** [make_in_channel buf] uses [buf] as a source of raw tar content. *) - -val make_out_channel : unit -> out_channel -(** [make_out_channel ()] returns a buffer to hold serialized tar content. *) - -val to_string : out_channel -> string -(** [to_string oc] returns the contents of [oc] as a string of bytes. *) - -val to_cstruct : out_channel -> Cstruct.t -(** [to_cstruct oc] returns the contents of [oc] as a {!Cstruct.t}. *) - -val really_read : in_channel -> Cstruct.t -> unit -(** [really_read ic buf] fills [buf] with data from [ic] or raises - {!Stdlib.End_of_file} *) - -val read_zerocopy : in_channel -> int -> Cstruct.t -(** [read_zerocopy ic len] updates the position and returns a sub cstruct of - [ic] or raises {!Stdlib.End_of_file} *) - -val skip : in_channel -> int -> unit - -val really_write : out_channel -> Cstruct.t -> unit -(** [really_write oc buf] writes the full contents of [buf] to [oc] - or raises {!Stdlib.End_of_file}. *) - -module HeaderReader : Tar.HEADERREADER with type in_channel = in_channel and type 'a io = 'a -module HeaderWriter : Tar.HEADERWRITER with type out_channel = out_channel and type 'a io = 'a