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 DAA19610; Thu, 31 Oct 2002 03:31:40 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 DAA19852 for ; Thu, 31 Oct 2002 03:31:39 +0100 (MET) Received: from stephens.ittc.ku.edu (stephens.ittc.ku.edu [129.237.125.220]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9V2VbD22284 for ; Thu, 31 Oct 2002 03:31:38 +0100 (MET) Received: from george.ittc.ku.edu (george.ittc.ku.edu [129.237.126.117]) by stephens.ittc.ku.edu (8.12.6/8.12.6/ITTC-ANTISPAM-ANTIVIRUS-3.0) with ESMTP id g9V2VXbc032395 for ; Wed, 30 Oct 2002 20:31:33 -0600 Date: Wed, 30 Oct 2002 20:31:33 -0600 (CST) From: Magesh Kannan To: caml-list@inria.fr Subject: [Caml-list] Question on 'really_input' Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-VirusScan: Clean Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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