caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Bruno.Verlyck@inria.fr
To: magesh@ittc.ku.edu
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Question on 'really_input'
Date: Thu, 31 Oct 2002 12:53:19 +0100	[thread overview]
Message-ID: <200210311153.g9VBrJS04386@waco.inria.fr> (raw)
In-Reply-To: <Pine.LNX.4.21.0210301953250.13227-100000@george.ittc.ku.edu> (magesh@ittc.ku.edu)

   Date: Wed, 30 Oct 2002 20:31:33 -0600 (CST)
   From: Magesh Kannan <magesh@ittc.ku.edu>

   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.

Bruno.
-------------------
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 11:53 UTC|newest]

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

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=200210311153.g9VBrJS04386@waco.inria.fr \
    --to=bruno.verlyck@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=magesh@ittc.ku.edu \
    /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).