Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the cstruct dependency #137

Merged
merged 19 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions bin/otar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,16 @@ module Tar_gz = Tar_gz.Make
let return x = x end)
(struct type out_channel = Stdlib.out_channel
type 'a io = 'a
let really_write oc cs =
let str = Cstruct.to_string cs in
let really_write oc str =
output_string oc str end)
(struct type in_channel = Stdlib.in_channel
type 'a io = 'a
let really_read ic cs =
let len = Cstruct.length cs in
let buf = Bytes.create len in
really_input ic buf 0 len ;
Cstruct.blit_from_bytes buf 0 cs 0 len
let skip ic len = really_read ic (Cstruct.create len)
let read ic cs =
let max = Cstruct.length cs in
let buf = Bytes.create max in
let len = input ic buf 0 max in
Cstruct.blit_from_bytes buf 0 cs 0 len ; len end)
let really_read ic buf =
really_input ic buf 0 (Bytes.length buf)
let skip ic len = seek_in ic len
hannesm marked this conversation as resolved.
Show resolved Hide resolved
hannesm marked this conversation as resolved.
Show resolved Hide resolved
let read ic buf =
input ic buf 0 (Bytes.length buf)
end)


let ( / ) = Filename.concat
Expand Down Expand Up @@ -107,7 +101,7 @@ let bytes_to_size ?(decimals = 2) ppf = function

let list filename =
let ic = open_in filename in
let ic = Tar_gz.of_in_channel ~internal:(Cstruct.create 0x1000) ic in
let ic = Tar_gz.of_in_channel ~internal:(De.bigstring_create 0x1000) ic in
let rec go global () = match Tar_gz.HeaderReader.read ~global ic with
| Ok (hdr, global) ->
Format.printf "%s (%s, %a)\n%!"
Expand Down
5 changes: 1 addition & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
(tags ("org:xapi-project" "org:mirage"))
(depends
(ocaml (>= 4.08.0))
(cstruct (>= 6.0.0))
(decompress (>= 1.5.1))
)
)
Expand All @@ -47,8 +46,6 @@
(tags ("org:xapi-project" "org:mirage"))
(depends
(ocaml (>= 4.08.0))
(cstruct (>= 6.0.0))
cstruct-lwt
lwt
(tar (= :version))
)
Expand All @@ -66,7 +63,7 @@
(conflicts (result (< 1.5)))
(depends
(ocaml (>= 4.08.0))
(cstruct (>= 1.9.0))
(cstruct (>= 6.0.0))
(lwt (>= 5.6.0))
(mirage-block (>= 2.0.0))
(mirage-clock (>= 4.0.0))
Expand Down
3 changes: 1 addition & 2 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(name tar)
(modules tar)
(public_name tar)
(wrapped false)
(libraries cstruct))
(wrapped false))

(library
(name tar_gz)
Expand Down
Loading
Loading