caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Question on 'really_input'
@ 2002-10-31  2:31 Magesh Kannan
  2002-10-31 11:53 ` Bruno.Verlyck
  0 siblings, 1 reply; 2+ messages in thread
From: Magesh Kannan @ 2002-10-31  2:31 UTC (permalink / raw)
  To: caml-list

Hi All,

I am writing a program that reads a file using multiple reads of a fixed 
size chunk. I tried using 'input' but input can read fewer bytes than
requested (and frequently does so; the ocaml implementation seems to read
4K blocks from the disk and if an 'input' call spans this boundary, the 
bytes left in the first block are returned, even if their length is less
than the requested length). 'really_input' seems to be a nice alternative
to do this, but there is a small problem.

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. Is this correct? If not, how do I find out how many bytes were
actually read? I cannot use String.length here, because it returns the
allocated length and not what is being used.

Can 'really_input' be used for such purposes? I can implement the behavior
of 'really_input' with the variation I am looking for, by running 'input' 
in a loop, but I wanted to make sure there is no built-in solution. BTW, I
have to read the file in fixed size chunks (and cannot issue a single read
using 'really_input' for the file's total size).

Thanks for your help,
Magesh

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-31 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-31  2:31 [Caml-list] Question on 'really_input' Magesh Kannan
2002-10-31 11:53 ` Bruno.Verlyck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).