Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Question on 'really_input'
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-10-31 (11:53)
From: Bruno.Verlyck@i...
Subject: Re: [Caml-list] Question on 'really_input'
   Date: Wed, 30 Oct 2002 20:31:33 -0600 (CST)
   From: Magesh Kannan <>

   During the last read from the file, if the number of bytes in the
   file is less than the requested length, 'really_input' reads
   whatever is available and also raises an exception, because EOF has
   been reached.  But there seems to be no way to find out how many
   bytes were actually read in this operation. [..]

   Can 'really_input' be used for such purposes?
Yes, no.  I understand that really_input is more useful with pipes, or
anything having no predefined size, but one can imagine workarounds
for your problem; e.g., you can get the current position with pos_in
before each really_input, then, on End_of_file, use seek_in and
String.length (input ..).  You can also compute the number of full
chunks in the file (the number of remaining bytes) by dividing (taking
the modulus of) the file size (in_channel_length) by the chunk size.

   I can implement the behavior of 'really_input' with the variation I
   am looking for, by running 'input' in a loop, but [..]
This is an equally good solution, given that really_input works by
looping too.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: