caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Magesh Kannan <magesh@ittc.ku.edu>
To: caml-list@inria.fr
Subject: [Caml-list] Question on 'really_input'
Date: Wed, 30 Oct 2002 20:31:33 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.21.0210301953250.13227-100000@george.ittc.ku.edu> (raw)

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


             reply	other threads:[~2002-10-31  2:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-31  2:31 Magesh Kannan [this message]
2002-10-31 11:53 ` Bruno.Verlyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0210301953250.13227-100000@george.ittc.ku.edu \
    --to=magesh@ittc.ku.edu \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).