Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Ed L Cashin <ecashin@uga.edu>
To: Chris Hecker <checker@d6.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] no tell on files?
Date: 04 Feb 2003 22:36:47 -0500	[thread overview]
Message-ID: <877kcfbdps.fsf@cs.uga.edu> (raw)
In-Reply-To: <200302050314.h153Eiu17604@plinky.bolt-action.com>

Chris Hecker <checker@d6.com> 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


  reply	other threads:[~2003-02-05  8:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-05  3:14 Chris Hecker
2003-02-05  3:36 ` Ed L Cashin [this message]
2003-02-05  3:52   ` Chris Hecker

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=877kcfbdps.fsf@cs.uga.edu \
    --to=ecashin@uga.edu \
    --cc=caml-list@inria.fr \
    --cc=checker@d6.com \
    /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