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 JAA26255; Wed, 5 Feb 2003 09:43:42 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA25777 for caml-list@pauillac.inria.fr; Wed, 5 Feb 2003 09:43:41 +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 EAA21269 for ; Wed, 5 Feb 2003 04:36:52 +0100 (MET) Received: from ajax.cs.uga.edu (ajax.cs.uga.edu [128.192.251.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h153aoP26143 for ; Wed, 5 Feb 2003 04:36:51 +0100 (MET) Received: from cs.uga.edu (ajax [128.192.251.3]) by ajax.cs.uga.edu (8.9.3/8.9.3) with ESMTP id WAA20947; Tue, 4 Feb 2003 22:36:47 -0500 (EST) To: Chris Hecker Cc: caml-list@inria.fr Subject: Re: [Caml-list] no tell on files? References: <200302050314.h153Eiu17604@plinky.bolt-action.com> From: Ed L Cashin Date: 04 Feb 2003 22:36:47 -0500 In-Reply-To: <200302050314.h153Eiu17604@plinky.bolt-action.com> Message-ID: <877kcfbdps.fsf@cs.uga.edu> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Chris Hecker writes: > There appears to be no "tell" function on pervasives streams or Unix > file descriptors. Is there a reason for this? The combination of > that plus the lack of a pervasives relative seek makes it hard to move > around in files without keeping parallel information. Seek is tell! The program below gives this output: ecashin@meili seek-tell$ ./a.out read 10 chars: " Unix.SEEK" let main = let fd = Unix.openfile "main.ml" [Unix.O_RDONLY] 0 in let end_pos = Unix.lseek fd 0 Unix.SEEK_END in let half_pos = Unix.lseek fd (end_pos/2) Unix.SEEK_SET and buf = String.create 1024 in Printf.printf "read %d chars: \"%s\"\n" (UnixLabels.read fd ~buf ~pos:0 ~len:10) buf ;; main -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ ------------------- 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