Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] really_input won't read in an entire file...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] really_input won't read in an entire file...
Am Samstag, den 08.04.2006, 22:58 +1200 schrieb Jonathan Roewen:
> Hi,
> 
> Here's an example running in the toplevel, which doesn't seem to work:
> 
> # let ic = open_in "C:/texture.raw";;

Use open_in_bin. Looks like a text/binary mode problem.

> val ic : in_channel = <abstr>
> # let len = in_channel_length ic;;
> val len : int = 196608
> # let buf = String.create len;;
> val buf : string = ....
> # really_input ic buf 0 len;;
> Exception: End_of_file.
> 
> Is reading it chunk-by-chunk the only reliable way to read in an
> entire file? Seems fairly useless to me...
> 
> Jonathan
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------