let slurp_ch ch =
let strsz = 8192 in
let buf = Buffer.create 1024 and str = String.make strsz '\x00' in
let rec inner cursz =
let insz = input ch str 0 strsz
in
if insz = 0
then Buffer.contents buf
else
(let newsz = cursz + insz
in
if newsz > Sys.max_string_length
then
failwith
("Filew.slurp_ch: file is bigger than " ^
((string_of_int Sys.max_string_length) ^ " bytes"))
else (Buffer.add_substring buf str 0 insz; inner newsz))
in inner 0