[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ed L Cashin <ecashin@u...> |
| Subject: | Re: [Caml-list] no tell on files? |
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