Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
- Remove Archive modules, and rework IO-specific modules (tar-unix etc);
  still work in progress
- Add `Tar.HEADERREADER` and `Tar.HEADERWRITER` module types, and rename
  `Tar.{READER,WRITER}.t` to `io`.
- When reading the compatibility level is no longer considered. In most
  cases the compatibility level was not enforced, and the semantics were
  very unclear.
- Better support for GNU LongLink/LongName
- Add a separate `write_global` function for writing a global
  `Tar.Header.Extended.t`. This allows writing an archive with a PAX
  comment and nothing else.

This is still work in progress.
  • Loading branch information
reynir committed Jun 13, 2023
1 parent fb02ab9 commit f7b0ca3
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 702 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

- `tar`: support pax Global Extended Headers. This adds state to tar parsing.
(#119, #120, @MisterDA)
- Support GNU LongLink and LongName. Prior, `Tar.HeaderWriter` and
`Tar.HeaderReader` supported both, but `Tar.Header.Link` only had `LongLink`
and (de)serialized to (from) GNU LongName.
- Compatibility level when reading / parsing is removed. Only GNU
LongLink/LongName extensions were affected by the compatibility level when
reading.
- Add module types `Tar.HEADERREADER` and `Tar.HEADERWRITER` describing the
output of `Tar.HeaderReader` and `Tar.HeaderWriter` respectively.
- Types `Tar.READER.t` and `Tar.WRITER.t` are renamed to `io`.

## v2.5.0 (2023-06-06)

Expand Down
10 changes: 5 additions & 5 deletions bin/otar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ module Tar_gz = Tar_gz.Make
let ( >>= ) x f = f x
let return x = x end)
(struct type out_channel = Stdlib.out_channel
type 'a t = 'a
type 'a io = 'a
let really_write oc cs =
let str = Cstruct.to_string cs in
output_string oc str end)
(struct type in_channel = Stdlib.in_channel
type 'a t = 'a
type 'a io = 'a
let really_read ic cs =
let len = Cstruct.length cs in
let buf = Bytes.create len in
Expand Down Expand Up @@ -104,8 +104,8 @@ 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 rec go global () = match Tar_gz.get_next_header ~global ic with
| (hdr, global) ->
let rec go global () = match Tar_gz.HeaderReader.read ~global ic with
| Ok (hdr, global) ->
Format.printf "%s (%a)\n%!"
hdr.Tar.Header.file_name
(bytes_to_size ~decimals:2) hdr.Tar.Header.file_size ;
Expand All @@ -116,7 +116,7 @@ let list filename =
let to_skip = Tar.Header.(Int64.to_int (to_sectors hdr) * length) in
Tar_gz.skip ic to_skip ;
go global ()
| exception Tar.Header.End_of_stream -> () in
| Error `Eof -> () in
go None ()

let () = match Sys.argv with
Expand Down
Loading

0 comments on commit f7b0ca3

Please sign in to comment.