English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Buffer.add_channel hangs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-03-17 (20:27)
From: Stas Miasnikou <stas.miasnikou@g...>
Subject: Buffer.add_channel hangs
Hi,

OCaml 3.11.1, OpenBSD 4.6, i386.

I am trying to read whole file by doing:

let read_file_bin name =
  let ic = open_in_bin name in
  let b = Buffer.create 1024 in
  (try Buffer.add_channel b ic max_int with _ -> ()); (* <-- HERE *)
  close_in ic;
  Array.init (Buffer.length b) (fun i -> int_of_char (Buffer.nth b i))

but it hangs on the line marked. Am I doing something wrong?

Stas