From fdd730299b28915878f2e0624b0d293bf9c4bd04 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Fri, 3 Nov 2023 14:52:29 +0100 Subject: [PATCH] Support eio>=0.12 --- eio/tar_eio.ml | 16 ++++++++-------- eio/tar_eio.mli | 18 +++++++++--------- tar-eio.opam | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/eio/tar_eio.ml b/eio/tar_eio.ml index b1d2c7f..af2f7ae 100644 --- a/eio/tar_eio.ml +++ b/eio/tar_eio.ml @@ -25,7 +25,7 @@ module Monad = struct end module Reader = struct - type in_channel = Flow.source + type in_channel = Flow.source_ty Resource.t type 'a t = 'a let really_read f b = Flow.read_exact f b let skip f (n: int) = @@ -43,7 +43,7 @@ end let really_read = Reader.really_read module Writer = struct - type out_channel = Flow.sink + type out_channel = Flow.sink_ty Resource.t type 'a t = 'a let really_write f b = Flow.write f [ b ] end @@ -66,7 +66,7 @@ module HR = Tar.HeaderReader(Monad)(Reader) module HW = Tar.HeaderWriter(Monad)(Writer) let get_next_header ?level ~global ic = - match HR.read ?level ~global (ic :> Flow.source) with + match HR.read ?level ~global ic with | Error `Eof -> None | Ok hdrs -> Some hdrs @@ -95,8 +95,8 @@ let header_of_file ?level ?getpwuid ?getgrgid filepath : Tar.Header.t = Tar.Header.make ~file_mode ~user_id ~group_id ~mod_time ~link_indicator ~link_name ?uname ?gname ~devmajor ~devminor (snd filepath) file_size -let write_block ?level ?global (header: Tar.Header.t) (body: #Flow.sink -> unit) sink = - HW.write ?level ?global header (sink :> Flow.sink); +let write_block ?level ?global (header: Tar.Header.t) body sink = + HW.write ?level ?global header sink; body sink; really_write sink (Tar.Header.zero_padding header) @@ -111,7 +111,7 @@ module Archive = struct should leave the fd positioned immediately after the datablock. Finally the function skips past the zero padding to the next header *) let with_next_file src ~(global: Tar.Header.Extended.t option) - (f: Eio.Flow.source -> Tar.Header.Extended.t option -> Tar.Header.t -> 'a) = + (f: _ -> Tar.Header.Extended.t option -> Tar.Header.t -> 'a) = match get_next_header ~global src with | Some (hdr, global) -> let result = f src global hdr in @@ -123,7 +123,7 @@ module Archive = struct (** List the contents of a tar *) let list ?level fd = let rec loop global acc = - match get_next_header ?level ~global (fd :> Flow.source) with + match get_next_header ?level ~global fd with | None -> List.rev acc | Some (hdr, global) -> Reader.skip fd (Int64.to_int hdr.Tar.Header.file_size); @@ -145,7 +145,7 @@ module Archive = struct in loop None () - let transform ?level f (ifd : #Flow.source) (ofd : #Flow.sink) = + let transform ?level f ifd ofd = let rec loop global () = match get_next_header ~global ifd with | None -> () diff --git a/eio/tar_eio.mli b/eio/tar_eio.mli index c604b7d..bc7f0aa 100644 --- a/eio/tar_eio.mli +++ b/eio/tar_eio.mli @@ -20,7 +20,7 @@ zero-filled blocks are discovered. Assumes stream is positioned at the possible start of a header block. @raise End_of_file if the stream unexpectedly fails. *) -val get_next_header : ?level:Tar.Header.compatibility -> global:Tar.Header.Extended.t option -> Eio.Flow.source -> +val get_next_header : ?level:Tar.Header.compatibility -> global:Tar.Header.Extended.t option -> Eio.Flow.source_ty Eio.Resource.t -> (Tar.Header.t * Tar.Header.Extended.t option) option (** Return the header needed for a particular file on disk. [getpwuid] and [getgrgid] are optional @@ -30,7 +30,7 @@ val header_of_file : ?level:Tar.Header.compatibility -> ?getpwuid:(int64 -> string) -> ?getgrgid:(int64 -> string) -> - Eio.Fs.dir Eio.Path.t -> + Eio.Fs.dir_ty Eio.Path.t -> Tar.Header.t module Archive : sig @@ -39,23 +39,23 @@ module Archive : sig (** Read the next header, apply the function 'f' to the source and the header. The function should leave the source positioned immediately after the datablock. Finally the function skips past the zero padding to the next header. *) - val with_next_file : Eio.Flow.source -> global:Tar.Header.Extended.t option -> - (Eio.Flow.source -> Tar.Header.Extended.t option -> Tar.Header.t -> 'a) -> 'a option + val with_next_file : Eio.Flow.source_ty Eio.Resource.t -> global:Tar.Header.Extended.t option -> + (Eio.Flow.source_ty Eio.Resource.t -> Tar.Header.Extended.t option -> Tar.Header.t -> 'a) -> 'a option (** List the contents of a tar to stdout. *) - val list : ?level:Tar.Header.compatibility -> #Eio.Flow.source -> Tar.Header.t list + val list : ?level:Tar.Header.compatibility -> Eio.Flow.source_ty Eio.Resource.t -> Tar.Header.t list (** [extract dest] extract the contents of a tar. Apply [dest] on each source filename to change the destination filename. It only supports extracting regular files from the top-level of the archive. *) - val extract : (string -> Eio.Fs.dir Eio.Path.t) -> Eio.Flow.source -> unit + val extract : (string -> Eio.Fs.dir_ty Eio.Path.t) -> Eio.Flow.source_ty Eio.Resource.t -> unit (** [transform f src sink] applies [f] to the header of each file in the tar inputted in [src], and writes the resulting headers to [sink] preserving the content and structure of the archive. *) - val transform : ?level:Tar.Header.compatibility -> (Tar.Header.t -> Tar.Header.t) -> #Eio.Flow.source -> #Eio.Flow.sink -> unit + val transform : ?level:Tar.Header.compatibility -> (Tar.Header.t -> Tar.Header.t) -> Eio.Flow.source_ty Eio.Resource.t -> Eio.Flow.sink_ty Eio.Resource.t -> unit (** Create a tar in the sink from a list of file paths. It only supports regular files. @@ -63,7 +63,7 @@ module Archive : sig val create : ?getpwuid:(int64 -> string) -> ?getgrgid:(int64 -> string) -> - Eio.Fs.dir Eio.Path.t list -> - #Eio.Flow.sink -> + Eio.Fs.dir_ty Eio.Path.t list -> + Eio.Flow.sink_ty Eio.Resource.t -> unit end diff --git a/tar-eio.opam b/tar-eio.opam index 697f742..55142dc 100644 --- a/tar-eio.opam +++ b/tar-eio.opam @@ -15,7 +15,7 @@ bug-reports: "https://github.com/mirage/ocaml-tar/issues" depends: [ "dune" {>= "2.9"} "ocaml" {>= "4.08.0"} - "eio" {>= "0.10.0" & < "0.12"} + "eio" {>= "0.12"} "tar" {= version} "odoc" {with-doc} ]