Skip to content

Commit d373f75

Browse files
committed
remove result (tar requires ocaml 4.03.0 anyways), require 4.05.0 for tar-mirage
1 parent aee659c commit d373f75

File tree

9 files changed

+30
-33
lines changed

9 files changed

+30
-33
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
- PINS="tar:. tar-unix:. tar-mirage:."
1111
matrix:
1212
- DISTRO="alpine" OCAML_VERSION="4.03" PACKAGE="tar-unix"
13-
- DISTRO="alpine" OCAML_VERSION="4.04" PACKAGE="tar-mirage"
13+
- DISTRO="alpine" OCAML_VERSION="4.04" PACKAGE="tar-unix"
1414
- DISTRO="alpine" OCAML_VERSION="4.05" PACKAGE="tar-mirage"
1515
- DISTRO="alpine" OCAML_VERSION="4.06" PACKAGE="tar-unix"
1616
- DISTRO="alpine" OCAML_VERSION="4.07" PACKAGE="tar-mirage"

Diff for: lib/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
(name tar)
33
(public_name tar)
44
(wrapped false)
5-
(libraries result cstruct re.str)
5+
(libraries cstruct re.str)
66
(flags :standard -safe-string)
77
(preprocess (pps ppx_cstruct)))

Diff for: lib/tar.ml

+22-22
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) =
556556
open Reader
557557

558558

559-
let read ?level (ifd: Reader.in_channel) : (Header.t, [ `Eof ]) Result.result t =
559+
let read ?level (ifd: Reader.in_channel) : (Header.t, [ `Eof ]) result t =
560560
let level = Header.get_level level in
561561
(* We might need to read 2 headers at once if we encounter a Pax header *)
562562
let buffer = Cstruct.create Header.length in
@@ -589,8 +589,8 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) =
589589
begin match Header.unmarshal ~level ~extended real_header_buf with
590590
| None ->
591591
(* Corrupt pax headers *)
592-
return (Result.Error `Eof)
593-
| Some x -> return (Result.Ok x)
592+
return (Error `Eof)
593+
| Some x -> return (Ok x)
594594
end
595595
| Some x when x.Header.link_indicator = Header.Link.LongLink && x.Header.file_name = longlink ->
596596
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) =
601601
let file_name = Cstruct.(to_string @@ sub extra_header_buf 0 (len extra_header_buf - 1)) in
602602
begin next ()
603603
>>= function
604-
| None -> return (Result.Error `Eof)
605-
| Some x -> return (Result.Ok { x with file_name })
604+
| None -> return (Error `Eof)
605+
| Some x -> return (Ok { x with file_name })
606606
end
607-
| Some x -> return (Result.Ok x)
607+
| Some x -> return (Ok x)
608608
| None ->
609609
begin
610610
next ()
611611
>>= function
612-
| Some x -> return (Result.Ok x)
613-
| None -> return (Result.Error `Eof)
612+
| Some x -> return (Ok x)
613+
| None -> return (Error `Eof)
614614
end in
615615

616-
let rec read_header (file_name, link_name, hdr) : (Header.t, [`Eof]) Result.result Async.t =
616+
let rec read_header (file_name, link_name, hdr) : (Header.t, [`Eof]) result Async.t =
617617
let raw_link_indicator = Header.get_hdr_link_indicator buffer in
618618
if (raw_link_indicator = 75 || raw_link_indicator = 76) && level = Header.GNU then
619619
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) =
625625
let data = Header.unmarshal_string (Cstruct.to_string data) in
626626
get_hdr ()
627627
>>= function
628-
| Result.Error `Eof -> return (Result.Error `Eof)
629-
| Result.Ok hdr ->
628+
| Error `Eof -> return (Error `Eof)
629+
| Ok hdr ->
630630
if raw_link_indicator = 75
631631
then read_header (file_name, data, hdr)
632632
else read_header (data, link_name, hdr)
633633
else begin
634634
let link_name = if link_name = "" then hdr.Header.link_name else link_name in
635635
let file_name = if file_name = "" then hdr.Header.file_name else file_name in
636-
return (Result.Ok {hdr with Header.link_name; file_name })
636+
return (Ok {hdr with Header.link_name; file_name })
637637
end in
638638
get_hdr ()
639639
>>= function
640-
| Result.Error `Eof -> return (Result.Error `Eof)
641-
| Result.Ok hdr ->
640+
| Error `Eof -> return (Error `Eof)
641+
| Ok hdr ->
642642
read_header ("", "", hdr)
643643

644644
end
@@ -775,11 +775,11 @@ module Make (IO : IO) = struct
775775
skips past the zero padding to the next header *)
776776
let with_next_file (fd: IO.in_channel) (f: IO.in_channel -> Header.t -> 'a) =
777777
match HR.read fd with
778-
| Result.Ok hdr ->
778+
| Ok hdr ->
779779
(* NB if the function 'f' fails we're boned *)
780780
finally (fun () -> f fd hdr)
781781
(fun () -> Reader.skip fd (Header.compute_zero_padding_length hdr))
782-
| Result.Error `Eof -> raise Header.End_of_stream
782+
| Error `Eof -> raise Header.End_of_stream
783783

784784
(** List the contents of a tar *)
785785
let list ?level fd =
@@ -788,11 +788,11 @@ module Make (IO : IO) = struct
788788
try
789789
while true do
790790
match HR.read ~level fd with
791-
| Result.Ok hdr ->
791+
| Ok hdr ->
792792
list := hdr :: !list;
793793
Reader.skip fd (Int64.to_int hdr.Header.file_size);
794794
Reader.skip fd (Header.compute_zero_padding_length hdr)
795-
| Result.Error `Eof -> raise Header.End_of_stream
795+
| Error `Eof -> raise Header.End_of_stream
796796
done;
797797
List.rev !list;
798798
with
@@ -821,14 +821,14 @@ module Make (IO : IO) = struct
821821
try
822822
while true do
823823
match HR.read ifd with
824-
| Result.Ok hdr ->
824+
| Ok hdr ->
825825
let size = hdr.Header.file_size in
826826
let padding = Header.compute_zero_padding_length hdr in
827827
let ofd = dest hdr in
828828
copy_n ifd ofd size;
829829
IO.close_out ofd;
830830
Reader.skip ifd padding
831-
| Result.Error `Eof -> raise Header.End_of_stream
831+
| Error `Eof -> raise Header.End_of_stream
832832
done
833833
with
834834
| End_of_file -> failwith "Unexpected end of file while reading stream"
@@ -850,8 +850,8 @@ module Make (IO : IO) = struct
850850
include Header
851851

852852
let get_next_header ?level ic = match HR.read ?level ic with
853-
| Result.Ok hdr -> hdr
854-
| Result.Error `Eof -> raise Header.End_of_stream
853+
| Ok hdr -> hdr
854+
| Error `Eof -> raise Header.End_of_stream
855855

856856
end
857857
end

Diff for: lib/tar.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ module HeaderReader(Async: ASYNC)(Reader: READER with type 'a t = 'a Async.t) :
150150
zero-filled blocks are discovered. Assumes stream is positioned at the
151151
possible start of a header block. End_of_file is thrown if the stream
152152
unexpectedly fails *)
153-
val read : ?level:Header.compatibility -> Reader.in_channel -> (Header.t, [`Eof]) Result.result Async.t
153+
val read : ?level:Header.compatibility -> Reader.in_channel -> (Header.t, [`Eof]) result Async.t
154154
end
155155

156156
module HeaderWriter(Async: ASYNC)(Writer: WRITER with type 'a t = 'a Async.t) : sig

Diff for: mirage/tar_mirage.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ module Make_KV_RO (BLOCK : Mirage_block_lwt.S) = struct
199199
let in_channel = { Reader.b; offset = 0L; info } in
200200
let rec loop map =
201201
HR.read in_channel >>= function
202-
| Result.Error `Eof -> Lwt.return map
203-
| Result.Ok tar ->
202+
| Error `Eof -> Lwt.return map
203+
| Ok tar ->
204204
let filename = trim_slash tar.Tar.Header.file_name in
205205
let data_tar_offset = Int64.div in_channel.Reader.offset 512L in
206206
let v_or_d = if is_dict filename then Dict (tar, StringMap.empty) else Value (tar, data_tar_offset) in

Diff for: tar-mirage.opam

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ homepage: "https://github.com/mirage/ocaml-tar"
66
doc: "https://mirage.github.io/ocaml-tar/"
77
bug-reports: "https://github.com/mirage/ocaml-tar/issues"
88
depends: [
9-
"ocaml" {>= "4.04.2"}
9+
"ocaml" {>= "4.05.0"}
1010
"dune" {build & >= "1.0"}
1111
"tar"
1212
"cstruct" {>= "1.9.0"}
1313
"re" {>="1.7.2"}
14-
"result"
1514
"mirage-block-unix" {with-test & >= "2.5.0"}
1615
"mirage-kv" {>= "2.0.0"}
1716
"mirage-kv-lwt" {>= "2.0.0"}

Diff for: tar-unix.opam

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ depends: [
1212
"cstruct" {>= "1.9.0"}
1313
"cstruct-lwt"
1414
"re"
15-
"result"
1615
"lwt"
1716
]
1817
build: [

Diff for: tar.opam

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ depends: [
1212
"ppx_cstruct" {>= "3.1.0"}
1313
"cstruct" {>= "1.9.0"}
1414
"re"
15-
"result"
1615
]
1716
build: [
1817
["dune" "subst"] {pinned}

Diff for: unix/tar_lwt_unix.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ module Header = struct
6363
let get_next_header ?level ic =
6464
HR.read ?level ic
6565
>>= function
66-
| Result.Error `Eof -> return None
67-
| Result.Ok hdr -> return (Some hdr)
66+
| Error `Eof -> return None
67+
| Ok hdr -> return (Some hdr)
6868

6969
(** Return the header needed for a particular file on disk *)
7070
let of_file ?level (file: string) : t Lwt.t =

0 commit comments

Comments
 (0)