Source

ocaml-bert / termreader.ml

Diff from to

File termreader.ml

 
 let print_termfile filename = 
+  let buflen = 1024 in
+  let buffer = String.create buflen in
   let load_file filename = 
     let rec load channel data = 
       try 
-	let line = Pervasives.input_line channel in
-	  load channel (String.concat "" [data; line])
+	begin match input channel buffer 0 buflen with
+	  | 0 -> 
+	      close_in channel;
+	      data;
+	  | bytes_read -> 
+	      load channel (String.concat "" [(String.sub buffer 0 bytes_read); data]);
+	end
       with
 	| End_of_file ->  
 	    close_in channel;