1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
let compress infile outfile =
let ic = open_in_bin infile
and oc = open_out_bin outfile in
Zlib.compress (fun buf -> input ic buf 0 (String.length buf))
(fun buf len -> output oc buf 0 len);
close_in ic;
close_out oc
let uncompress infile outfile =
let ic = open_in_bin infile
and oc = open_out_bin outfile in
Zlib.uncompress (fun buf -> input ic buf 0 (String.length buf))
(fun buf len -> output oc buf 0 len);
close_in ic;
close_out oc
let _ =
if Array.length Sys.argv >= 4 && Sys.argv.(1) = "-d" then
uncompress Sys.argv.(2) Sys.argv.(3)
else if Array.length Sys.argv >= 3 then
compress Sys.argv.(1) Sys.argv.(2)
|