From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA31387; Thu, 31 Oct 2002 12:53:27 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA31104 for ; Thu, 31 Oct 2002 12:53:27 +0100 (MET) Received: from waco.inria.fr (waco.inria.fr [128.93.25.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9VBrJD02459; Thu, 31 Oct 2002 12:53:20 +0100 (MET) Received: (from verlyck@localhost) by waco.inria.fr (8.11.1/8.11.1) id g9VBrJS04386; Thu, 31 Oct 2002 12:53:19 +0100 Date: Thu, 31 Oct 2002 12:53:19 +0100 Message-Id: <200210311153.g9VBrJS04386@waco.inria.fr> X-Authentication-Warning: waco.inria.fr: verlyck set sender to Bruno.Verlyck@inria.fr using -f To: magesh@ittc.ku.edu CC: caml-list@inria.fr In-reply-to: (magesh@ittc.ku.edu) Subject: Re: [Caml-list] Question on 'really_input' From: Bruno.Verlyck@inria.fr References: Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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. 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