diff --git a/.travis.yml b/.travis.yml index f5c2966..eac2372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - PINS="tar:. tar-unix:. tar-mirage:." matrix: - DISTRO="alpine" OCAML_VERSION="4.03" PACKAGE="tar-unix" - - DISTRO="alpine" OCAML_VERSION="4.04" PACKAGE="tar-mirage" + - DISTRO="alpine" OCAML_VERSION="4.04" PACKAGE="tar-unix" - DISTRO="alpine" OCAML_VERSION="4.05" PACKAGE="tar-mirage" - DISTRO="alpine" OCAML_VERSION="4.06" PACKAGE="tar-unix" - DISTRO="alpine" OCAML_VERSION="4.07" PACKAGE="tar-mirage" diff --git a/lib/dune b/lib/dune index 8377c7b..2aa4c30 100644 --- a/lib/dune +++ b/lib/dune @@ -2,6 +2,6 @@ (name tar) (public_name tar) (wrapped false) - (libraries result cstruct re.str) + (libraries cstruct re.str) (flags :standard -safe-string) (preprocess (pps ppx_cstruct))) diff --git a/lib/tar.ml b/lib/tar.ml index 4344693..f52279b 100644 --- a/lib/tar.ml +++ b/lib/tar.ml @@ -556,7 +556,7 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) = open Reader - let read ?level (ifd: Reader.in_channel) : (Header.t, [ `Eof ]) Result.result t = + let read ?level (ifd: Reader.in_channel) : (Header.t, [ `Eof ]) result t = let level = Header.get_level level in (* We might need to read 2 headers at once if we encounter a Pax header *) let buffer = Cstruct.create Header.length in @@ -589,8 +589,8 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) = begin match Header.unmarshal ~level ~extended real_header_buf with | None -> (* Corrupt pax headers *) - return (Result.Error `Eof) - | Some x -> return (Result.Ok x) + return (Error `Eof) + | Some x -> return (Ok x) end | Some x when x.Header.link_indicator = Header.Link.LongLink && x.Header.file_name = longlink -> let extra_header_buf = Cstruct.create (Int64.to_int x.Header.file_size) in @@ -601,19 +601,19 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) = let file_name = Cstruct.(to_string @@ sub extra_header_buf 0 (len extra_header_buf - 1)) in begin next () >>= function - | None -> return (Result.Error `Eof) - | Some x -> return (Result.Ok { x with file_name }) + | None -> return (Error `Eof) + | Some x -> return (Ok { x with file_name }) end - | Some x -> return (Result.Ok x) + | Some x -> return (Ok x) | None -> begin next () >>= function - | Some x -> return (Result.Ok x) - | None -> return (Result.Error `Eof) + | Some x -> return (Ok x) + | None -> return (Error `Eof) end in - let rec read_header (file_name, link_name, hdr) : (Header.t, [`Eof]) Result.result Async.t = + let rec read_header (file_name, link_name, hdr) : (Header.t, [`Eof]) result Async.t = let raw_link_indicator = Header.get_hdr_link_indicator buffer in if (raw_link_indicator = 75 || raw_link_indicator = 76) && level = Header.GNU then let data = Cstruct.create (Int64.to_int hdr.Header.file_size) in @@ -625,20 +625,20 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) = let data = Header.unmarshal_string (Cstruct.to_string data) in get_hdr () >>= function - | Result.Error `Eof -> return (Result.Error `Eof) - | Result.Ok hdr -> + | Error `Eof -> return (Error `Eof) + | Ok hdr -> if raw_link_indicator = 75 then read_header (file_name, data, hdr) else read_header (data, link_name, hdr) else begin let link_name = if link_name = "" then hdr.Header.link_name else link_name in let file_name = if file_name = "" then hdr.Header.file_name else file_name in - return (Result.Ok {hdr with Header.link_name; file_name }) + return (Ok {hdr with Header.link_name; file_name }) end in get_hdr () >>= function - | Result.Error `Eof -> return (Result.Error `Eof) - | Result.Ok hdr -> + | Error `Eof -> return (Error `Eof) + | Ok hdr -> read_header ("", "", hdr) end @@ -775,11 +775,11 @@ module Make (IO : IO) = struct skips past the zero padding to the next header *) let with_next_file (fd: IO.in_channel) (f: IO.in_channel -> Header.t -> 'a) = match HR.read fd with - | Result.Ok hdr -> + | Ok hdr -> (* NB if the function 'f' fails we're boned *) finally (fun () -> f fd hdr) (fun () -> Reader.skip fd (Header.compute_zero_padding_length hdr)) - | Result.Error `Eof -> raise Header.End_of_stream + | Error `Eof -> raise Header.End_of_stream (** List the contents of a tar *) let list ?level fd = @@ -788,11 +788,11 @@ module Make (IO : IO) = struct try while true do match HR.read ~level fd with - | Result.Ok hdr -> + | Ok hdr -> list := hdr :: !list; Reader.skip fd (Int64.to_int hdr.Header.file_size); Reader.skip fd (Header.compute_zero_padding_length hdr) - | Result.Error `Eof -> raise Header.End_of_stream + | Error `Eof -> raise Header.End_of_stream done; List.rev !list; with @@ -821,14 +821,14 @@ module Make (IO : IO) = struct try while true do match HR.read ifd with - | Result.Ok hdr -> + | Ok hdr -> let size = hdr.Header.file_size in let padding = Header.compute_zero_padding_length hdr in let ofd = dest hdr in copy_n ifd ofd size; IO.close_out ofd; Reader.skip ifd padding - | Result.Error `Eof -> raise Header.End_of_stream + | Error `Eof -> raise Header.End_of_stream done with | End_of_file -> failwith "Unexpected end of file while reading stream" @@ -850,8 +850,8 @@ module Make (IO : IO) = struct include Header let get_next_header ?level ic = match HR.read ?level ic with - | Result.Ok hdr -> hdr - | Result.Error `Eof -> raise Header.End_of_stream + | Ok hdr -> hdr + | Error `Eof -> raise Header.End_of_stream end end diff --git a/lib/tar.mli b/lib/tar.mli index 2a80cd1..5f8566c 100644 --- a/lib/tar.mli +++ b/lib/tar.mli @@ -150,7 +150,7 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) : zero-filled blocks are discovered. Assumes stream is positioned at the possible start of a header block. End_of_file is thrown if the stream unexpectedly fails *) - val read : ?level:Header.compatibility -> Reader.in_channel -> (Header.t, [`Eof]) Result.result Async.t + val read : ?level:Header.compatibility -> Reader.in_channel -> (Header.t, [`Eof]) result Async.t end module HeaderWriter(Async: ASYNC)(Writer: WRITER with type 'a t = 'a Async.t) : sig diff --git a/mirage/tar_mirage.ml b/mirage/tar_mirage.ml index 7e12875..3fe1c9e 100644 --- a/mirage/tar_mirage.ml +++ b/mirage/tar_mirage.ml @@ -199,8 +199,8 @@ module Make_KV_RO (BLOCK : Mirage_block_lwt.S) = struct let in_channel = { Reader.b; offset = 0L; info } in let rec loop map = HR.read in_channel >>= function - | Result.Error `Eof -> Lwt.return map - | Result.Ok tar -> + | Error `Eof -> Lwt.return map + | Ok tar -> let filename = trim_slash tar.Tar.Header.file_name in let data_tar_offset = Int64.div in_channel.Reader.offset 512L in let v_or_d = if is_dict filename then Dict (tar, StringMap.empty) else Value (tar, data_tar_offset) in diff --git a/tar-mirage.opam b/tar-mirage.opam index 71edf6f..1a71dac 100644 --- a/tar-mirage.opam +++ b/tar-mirage.opam @@ -6,12 +6,11 @@ homepage: "https://github.com/mirage/ocaml-tar" doc: "https://mirage.github.io/ocaml-tar/" bug-reports: "https://github.com/mirage/ocaml-tar/issues" depends: [ - "ocaml" {>= "4.04.2"} + "ocaml" {>= "4.05.0"} "dune" {build & >= "1.0"} "tar" "cstruct" {>= "1.9.0"} "re" {>="1.7.2"} - "result" "mirage-block-unix" {with-test & >= "2.5.0"} "mirage-kv" {>= "2.0.0"} "mirage-kv-lwt" {>= "2.0.0"} diff --git a/tar-unix.opam b/tar-unix.opam index 2dd351c..18d24c2 100644 --- a/tar-unix.opam +++ b/tar-unix.opam @@ -12,7 +12,6 @@ depends: [ "cstruct" {>= "1.9.0"} "cstruct-lwt" "re" - "result" "lwt" ] build: [ diff --git a/tar.opam b/tar.opam index 6691296..ca2de99 100644 --- a/tar.opam +++ b/tar.opam @@ -12,7 +12,6 @@ depends: [ "ppx_cstruct" {>= "3.1.0"} "cstruct" {>= "1.9.0"} "re" - "result" ] build: [ ["dune" "subst"] {pinned} diff --git a/unix/tar_lwt_unix.ml b/unix/tar_lwt_unix.ml index 5e9f9ba..d3056ff 100644 --- a/unix/tar_lwt_unix.ml +++ b/unix/tar_lwt_unix.ml @@ -63,8 +63,8 @@ module Header = struct let get_next_header ?level ic = HR.read ?level ic >>= function - | Result.Error `Eof -> return None - | Result.Ok hdr -> return (Some hdr) + | Error `Eof -> return None + | Ok hdr -> return (Some hdr) (** Return the header needed for a particular file on disk *) let of_file ?level (file: string) : t Lwt.t =