26 lines
601 B
OCaml
26 lines
601 B
OCaml
(** Base archive utitlities *)
|
|
|
|
module Zip = Zip
|
|
module Xz = Xz
|
|
module Cpio = Cpio
|
|
|
|
type t = { file : string; typ : string }
|
|
|
|
let is_signature infile signature =
|
|
(* assume infile pos is 0 *)
|
|
let accumulator acc s =
|
|
match In_channel.input_char infile with
|
|
| None -> false
|
|
| Some c -> s == c && acc
|
|
in
|
|
Bytes.fold_left accumulator true signature
|
|
|
|
(** matching common archive signatures *)
|
|
let from file =
|
|
let infile = In_channel.open_bin file in
|
|
(* support for zip file for now *)
|
|
if is_signature infile Zip.signature then
|
|
Some { file = file; typ = "zip"; }
|
|
else
|
|
None
|