File: buffer_ex.ml

package info (click to toggle)
ocaml-res 5.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: ml: 1,479; makefile: 22
file content (8 lines) | stat: -rw-r--r-- 342 bytes parent folder | download
1
2
3
4
5
6
7
8
(* Reads a file given as first argument into a buffer and prints it out again.
   Uses an exponentially growing read-ahead during reading (just for
   demonstration). *)

let _ =
  let buf = Res.Buffer.empty () and file = open_in Sys.argv.(1) in
  Res.Buffer.add_full_channel_f buf file 50000 (( * ) 2);
  Res.Buffer.output_buffer stdout buf